Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between tp5 and laravel

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what are the differences between tp5 and laravel, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The difference: 1. When submitting a form, Laravel needs to add "@ csrf" to the form to prevent cross-domain attacks, while tp does not need to be added; 2. Laravel uses "Db:: operation ('native sql')" for native queries, while tp uses "Db::query (' native sql')" for native queries.

The operating environment of this tutorial: windows10 system, Laravel6 version, DELL G3 computer.

What's the difference between tp5 and laravel?

I. differences between TP5 and Laravel frameworks

Difference:

1. How to submit data. Laravel needs to add @ csrf or {undefined {csrf_token ()}} to the form when submitting the form to prevent cross-domain attacks, while TP will not.

2. For routing, Laravel must be defined before use. After routing is enabled for routes.php,TP in the configuration file, the routing format is: 'routing expression' = > 'routing address and parameters' (the premise for using routing is that URL supports phthinfo and enables routing). Routing can make URL more consistent with SEO.

3. Middleware, the middleware of Laravel, middleware is the layer through which the HTTP request arrives. Through the middleware, we can verify whether the user is logged in and other general operations.

4. To operate the database, you can use instantiation (establishing the corresponding model class) and DB:table ('table name') to operate the database. It is not the same when using native queries. Laravel uses Db:: operation ('native sql') and TP uses Db::query (' native sql').

5. Upgrading Laravel is very easy, while upgrading a large version of TP requires refactoring the code.

6. Differences in the writing style of conditional judgment sentences:

In Laravel framework, if else judgment statement and foreach statement must start with @ if and end with @ endif. If not, a syntax error is reported. @ foreach @ endforeach is the same.

The TP framework is consistent with the use of PHP grammar rules, direct ifesle statement judgment and foreach loop traversal.

II. CSRF protection

CSRF cross-site request forgery (Cross-Site Request Forgery), like XSS attacks, has great harmfulness.

Defend against CSRF attacks:

At present, there are three main strategies to defend against CSRF attacks: verify the HTTP Referer field; add token to the request address and verify it; and customize the attribute in the HTTP header and verify it.

These are all the contents of this article entitled "what are the differences between tp5 and laravel". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report