Joke Collection Website - Public benefit messages - What are the routing rules of laravel's RESTful controller?

What are the routing rules of laravel's RESTful controller?

The main technical features of Laravel are: 1, and Bundle is the organizational form or title of Laravel's expansion package. Laravel's expansion package library is quite mature, and it can easily help you install the expansion package into your application. You can choose to download an expansion package and copy it to the package directory, or install it automatically through the command line tool "Artisan". 2.Laravel already has a set of advanced PHP ActiveRecord implementation-eloquent ORM. It can easily apply "constraints" to both sides of the relationship, giving you complete control over the data and enjoying all the conveniences of ActiveRecord. In Fluent, eloquence naturally supports all methods of query builder. 3. The application logic can be implemented in the controller or directly integrated into the routing statement, and the syntax is similar to Sinatra framework. Laravel's design philosophy is: to give developers the greatest flexibility, not only to create very small websites, but also to build large-scale enterprise applications. 4. Reverse routing enables you to create a link (URIs) by routing name. Just use the route name and Laravel will automatically create the correct URI for you. So you can change your route at any time, and Laravel will automatically update all relevant links for you. 5.Restful controller is an optional way to distinguish between GET and POST request logic. For example, in a user login logic, you declare a get_login () action to handle the service of getting the login page; At the same time, a POST_login () operation is also declared to verify the data submitted by the form. After verification, it is decided whether to redirect to the login page or the console. 6. The automatic loading of classes simplifies the loading of classes, and there is no need to maintain the automatic loading configuration table and unnecessary component loading in the future. When you want to load any library or model, as long as you use it immediately, Laravel will automatically load the required files for you. 7. View Composer is essentially a piece of code that will be automatically executed when the view is loaded. The best example is the random article recommendation in the blog. The "View Assembler" contains the logic of loading random article recommendations, so that you only need to load the view of the content area, and Laravel will automatically help you with other things. 8.IoC container provides a convenient way to generate new objects, instantiate objects at any time and access singleton objects. Inverse control (IoC) means that you can access these objects anywhere in your code without loading external libraries or putting up with complex and redundant code structures. 9. Migration is like a version control tool, but it manages the database paradigm and is directly integrated in Laravel. You can use the "Artisan" command line tool to generate and execute the "migration" instructions. When your team members change the database paradigm, you can easily update the current project through the version control tool, and then execute the "migration" instruction. Well, your database is up to date! 10 and unit testing are very important parts in Laravel. Laravel itself contains hundreds of test cases to ensure that any modification will not affect the functions of other parts, which is one of the reasons why Laravel is considered to be the most stable version in the industry. Laravel also provides convenient functions that make it easy for your own code to be unit tested. All test cases can be run through the Artisan command-line tool. 1 1, the automatic paging function avoids mixing a lot of irrelevant paging configuration codes into your business logic. Conveniently, you don't need to remember the current page, just get the total number of entries from the database, then use limit/offset to get the selected data, and finally call the' paginate' method to let Laravel output the links of each page to the specified view, and Laravel will automatically complete all the work for you. Laravel's automatic paging system is designed to be easy to implement and modify. Although Laravel can handle these tasks automatically, don't forget to call the corresponding methods and manually configure the paging system! Let's use a few small examples to explain: Micro-service and program interface Lumen is a micro-framework from laravel, focusing on simplification. Its high-performance programming interface allows you to develop micro-projects more simply and quickly. Lumen integrates all the important features of laravel with minimal configuration, and you can migrate the complete framework by copying the code to laravel project. & lt? PHP $ app-& gt; get('/'),function(){ return view(' lumen '); }); $ app-& gt; post('framework/{id} ',function($ framework){ $ this-& gt; Scheduling (new energy ($ framework)); }); HTTP path Laravel has a fast and efficient routing system similar to Ruby on Rails. It allows users to associate all parts of the application by entering a path in the browser. HTTP middleware route:: get ('/', function(){ return' hello world ';; }); Middleware can protect applications-middleware will process, analyze and filter HTTP requests on the server. You can install middleware to verify registered users and avoid cross-site scripting (XSS) or other security issues. & lt? Php namespace App \ Http \ Middleware uses closures; Class OldMiddleware {public function handle ($request, closure $ next) {if ($ request->; Enter ('age')< = 200) {return redirect ('home'); } return $ next($ request); Caching your application can get a robust caching system. By adjusting, the application can load faster, which can provide the best experience for your users. Cache::extend('mongo', function ($ app) {return cache:: repository (new mongo store); }); Authentication security is very important. Laravel provides authentication for local users, and you can use the "Remember" option to remember users. It also allows you, for example, some additional parameters, such as whether the monitor is an active user. if(Auth::attempt([' email ' = & gt; $email,' password' = & gt$password,' active' => 1], $ remember) {/Users are being remembered ...} Various integrated Laravel Cashier can meet all your needs in developing payment systems. In addition, it is synchronized and integrated into the user authentication system. Therefore, you no longer need to worry about how to integrate the billing system into the development. $ User = User::find( 1); $ user-& gt; Subscription ('monthly')-> create($ credit card token); Task automation Elixir is a Laravel program interface that allows us to define tasks with Gulp. We can use Elixir to define preprocessors that can simplify CSS and JavaScript. elixir(function(mix){ mix . browser ify(' main . js '); }); Encrypted secure applications should be able to encrypt data. With Laravel, you can enable the OpenSSL security encryption algorithm AES-256-CBC to meet all your needs. In addition, all encrypted values are signed by a verification code, which detects whether the encrypted information has been changed. Use illuminate \ contracts \ encryption \ decrypt exception; try { $ decrypted = Crypt::decrypt($ encrypted value); The definition, recording and monitoring of events in the event processing application are very fast. The listen in the EventServiceProvider event contains a list of all events recorded in the application. protected $ listen =[' App \ Events \ podcast was purchased ' = & gt; [' App \ Listeners \ EmailPurchaseConfirmation ',],]; Pagination in Laravel is very easy because it can generate a series of links according to the current page of the user's browser. & lt? Php namespace App \ Http \ Controllers uses db; Use app \ http \ controllers \ controller; The UserController class extends the controller {public function index () {$ users = db:: table ('users')->; Pagination (15); Return to view ('user.index', ['users' = > $ users]); }} Object Relational Mapping (ORM) Laravel contains a layer dealing with databases, and its object relational mapping is called eloquence. In addition, this also applies to PostgreSQL. $users = User::where('votes ',' & gt, 100)->; Take (10)->; get(); foreach($ users as $ user){ var _ dump($ user-& gt; Name); The development of unit test is a time-consuming work, but it is the key to ensure that our application keeps working normally. PHPUnit can be used to perform unit tests in Laravel. & ltphp uses lighting \ basic \ testing \ without middleware; Use illuminate \ foundation \ testing \ database transactions; Class ExampleTest extends test case {public function test basic example () {$ this-> Please visit ('/')-> See ('Laravel 5 ')-& gt;; don tsee(' Rails '); }} To-Do List Laravel provides the option to use to-do lists to handle complex and lengthy processes in the background. It allows us to handle certain processes asynchronously without continuous navigation by users. queue::push(new send email($ message));