Home >PHP Framework >Laravel >Take you to learn more about the difference between laravel framework and thinkPHP framework

Take you to learn more about the difference between laravel framework and thinkPHP framework

烟雨青岚
烟雨青岚forward
2020-07-18 13:21:323632browse

Take you to learn more about the difference between laravel framework and thinkPHP framework

Main difference: (thinkPHP is more suitable for Chinese coding habits)

1. Differences in rendering template methods:

In the Laravl framework, return view() is used to render the template;

In ThinkPHP, $this->display() is used to render the template;

2. In the Laravel framework, since it takes into account cross-site request forgery

, if you use the form form to pass values ​​in post mode, if it is no longer in the form form Adding {{csrf_field()}} will report a syntax error of TokenMethodnotfound;

The TP framework needs to manually complete the code to prevent cross-site attacks;

3.Laravel It is a rerouting framework (5.4). All functions are initiated by routing. Even if there is no controller method, you can access it as long as you write the route. ThinkPHP (3.2) must have a controller method to function normally. Visit;

4.laravel has a powerful community extension, (composer extension is automatically loaded);

5.laravel has a powerful Blade template engine;

6. Middleware, Laravel features, can realize processing before and after access, such as request and return, permission authentication, etc.;

7. Differences in the way of writing conditional judgment statements:

If else judgment statements and foreach statements in the Laravel framework must start with @if and end with @endif. If not, a syntax error will be reported, @ The same applies to foreach and @endforeach;

The TP framework is used in the same way as PHP grammar rules. Direct ifesle statement judgment and foreach loop traversal

Laravel has a lot of built-in The method is for developers to use. In actual applications, it is closer to the development idea of ​​"let the object do everything". For example, during background form verification

Laravel has a large number of built-in verification methods, such as verification of user names. : We use 'username'=>'required' (cannot be empty) in the validate method | alpha_dash (must have numbers, letters and underlines) | between: 6,18 (between the number of digits); and also built-in e-mail; Same: field name; diff: field name and many other methods greatly improve the development speed;

Encryption method

In the TP framework When we encrypt the user name and password, we use md5(); to encrypt. However, the disadvantage of md5 is that it can be reversely cracked, and under the same rules, the strings encrypted by md5 for the same password may appear the same. This Just reduce its security;

But the "Hash" Hash encryption one-way encryption method is built into the Laravel framework, and the string encrypted with the same parameters will never have the same situation. This improves security;

In actual development, we often encounter such a problem, that is, the development location is not fixed, which causes us to frequently change the database configuration, causing trouble to the development work. TP still has not avoided this "disaster";

In the laravel framework, the emergence of .env environment files solves this trouble. We only need to configure the .env files in different work locations without having to configure them again. Because whether it is git or svn ".env will not be submitted to the server along with the file";

Thank you everyone for reading, I hope you will benefit.

Recommended tutorial: "Laravel Tutorial"

The above is the detailed content of Take you to learn more about the difference between laravel framework and thinkPHP framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete