The difference between thinkphp5 and laravel: 1. Thinkphp uses the "$this->display()" method to render templates, while Laravel uses "return view()"; 2. The cross-site method is different; 3. The routing is different; 4. Thinkphp does not have middleware, but Laravel has middleware; 5. The encryption methods are different.
The operating environment of this tutorial: windows7 system, Laravel6&&thinkphp5 version, DELL G3 computer.
What are the differences between the Laravel framework and the thinkphp5 framework
The first is the difference in the way they render templates:
Thinkphp statement is: $this->display()
Laravel statement is: return view()
The second is that their cross-site methods are different:
Thinkphp needs to manually complete the code to prevent cross-site attacks
Laravel considers cross-transfer request forgery, uses the form form to pass the value in post mode, and adds {{ to the form form csrf_field() }} to complete, if {{csrf_field}} is not added, the token error will be displayed
The third point is that the routing is different:
Thinkphp (3.2) It is necessary to fill in the controller, otherwise it will not be accessible
Lavarel is a rerouting framework, and all functions are initiated by routing. It can have no controller methods, no models, and no views, but it must have routing.
The fourth point is middleware:
Thinkphp: No middleware
Laravel: With middleware, it can realize processing before and after access (request and return, authority authentication, etc.)
The fifth point is the encryption method is different:
Thinkphp: It uses the md5() encryption algorithm in thinkphp's built-in algorithm. It is easy to be reverse-engineered and forcibly broken by the outside world.
Laravel: It uses built-in hash encryption (one-way encryption method), and there is no reverse cracking.
Laravel has a large number of built-in methods for developers to use. In practical 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 username: we use 'username'=>'required in the validate method '(cannot be empty) | alpha_dash (must have numbers, letters and underlines), etc.
The sixth point is the difference between If and foreach statements:
Thinkphp: and in native php The writing method is consistent
Laravel: Be sure to add the @ symbol (@if-@endif @foreach-@endforeach) when writing
[Related recommendations: laravel tutorial, thinkphp tutorial】
The above is the detailed content of What is the difference between thinkphp5 and laravel. For more information, please follow other related articles on the PHP Chinese website!