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's the difference between Tp5 and laravel?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, the editor will share with you the relevant knowledge of what is the difference between Tp5 and laravel. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Differences: 1, when the form is submitted, Laravel needs to add "@ csrf" to the form to prevent cross-domain attacks, but TP5 does not use; 2, Laravel will have middleware before the request, Tp5 will have pre-operations and hooks; 3, the native query way to operate the database is different.

The operating environment of this tutorial: Windows7 system, thinkphp 5.1&&Laravel6 version, Dell G3 computer.

ThinkPHP is a free and open source, fast, simple, object-oriented lightweight PHP development framework, which was born for agile WEB application development and simplifying enterprise application development. With ThinkPHP, you can develop and deploy applications more easily and quickly, not just enterprise applications, but any PHP application development can benefit from the simple, compatible and fast features of ThinkPHP.

Laravel is a concise and elegant PHP Web development framework (PHP Web Framework). It frees you from the noodle-like clutter of code; it helps you build a perfect web APP, and every line of code can be concise and expressive.

The difference between ThinkPHP5 and laravel

1. Submit data

Laravel needs to add @ csrf or {undefined {csrf_token ()}} to the form when submitting the form to prevent cross-domain attacks, while TP5 does not.

2. Route usage

Laravel must be defined and then used. The route file is routes.php, while Tp5 can be undefined and can be accessed with pathinfo routing.

When TP enables routing 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 routing is enabled). Routing can make URL more SEO-compliant.

3. Laravel will have middleware before request, and Tp5 will have pre-operation and hook.

4. Operation of database and native query

In the way you operate the database, you can use instantiation (creating 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:: operations ('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. The difference 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.

These are all the contents of the article "what's the difference between Tp5 and laravel". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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