Home>Article>PHP Framework> The difference between laravel framework and thinkPHP framework

The difference between laravel framework and thinkPHP framework

L
L forward
2020-05-29 10:47:42 7175browse

The difference between the laravel framework and thinkPHP framework

Main differences:

1. The difference in rendering template methods:

In the Laravel framework, Use return view() to render the template;

And ThinkPHP uses $this->display() to render the template;

2. In the Laravel framework, due to its considerations It’s cross-site request forgery, so if you use the form form to pass values in the post method, if you don’t add {{csrf_field()}} to the form form, a syntax error of TokenMethodnotfound will be reported;

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

3. Laravel is a rerouting framework (5.4). All functions are initiated by routing. Even if there is no controller method, just write You can access it by routing, thinkPHP (3.2), you must have a controller method for normal access;

4. Laravel has powerful community extensions (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. Conditional judgment Differences in the way statements are written:

The if else judgment statement and the foreach statement in the Laravel framework must start with @if and end with @endif. If not, a syntax error will be reported. The same is true for @foreach@endforeach; and TP The framework is used in the same way as PHP syntax rules, direct ifesle statement judgment and foreach loop traversal

8. Laravel has a large number of built-in methods for developers to use, which in actual applications is closer to "let the object do everything" Development ideas, for example, during background form verification, Laravel has a large number of built-in verification methods, such as verification of username: we use 'username'=>'required' (cannot be empty)|alpha_dash( in the validate method Must have numbers, letters and underlines) | between: 6, 18 (between the number of digits); It also has built-in a large number of methods such as email; same: field name; diff: field name, etc., which greatly improves the development speed;

9. Encryption method In the TP framework, we use md5(); to encrypt usernames and passwords. However, the disadvantage of md5 is that it can be reversely cracked, and the same password md5 is encrypted under the same rules. The strings may appear the same, which reduces its security; however, the "hash" Hash encryption one-way encryption method is built into the Laravel framework, and the strings encrypted with the same parameters will never appear the same. This improves security;

10. 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, which greatly affects the development work. Caused trouble, TP still did not avoid this "disaster"; in the laravel framework, the emergence of .env environment files solved this trouble. We only need to configure the .env files in different work locations and do not need to configure them again, because no matter Is it git or svn ".env will not be submitted to the server along with the file";

Related recommendations:《TP5》《laravel

The above is the detailed content of 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