I’ve been learning the laravel framework recently, and I find it difficult to get started. Take route mapping as an example, you have to configure it yourself. It feels very troublesome. When writing a controller, you need to configure a route. It is not as simple as the automatic mapping of tp and yii. I feel that such a powerful framework shouldn't be so troublesome. Is it because I don't know how to configure a default routing mapping rule?
It’s not difficult. It’s the design ideas that are different.
You actually like...?controller=xx&action=xxx style.
Recommend a Laravel learning website to the questioner, explained by Chinese people themselves.
https://laravist.com/
Although Laravel itself has relatively complete documentation and API, if you only look at the documentation and API, there may indeed be some obstacles for many unfamiliar web developers. It is recommended to refer to:
Laracasts, a detailed step-by-step teaching video;
laravel.io/forum, a laravel forum that covers many issues;
laravel 5 book, a laravel teaching book that can be read online.
Code Bright written by Dayle Rees can also be read, it will explain many reasons for Laravel's internal mechanism.
Laravel uses a more elegant way to grasp many details, so it calls itself "The PHP Framework For Web Artisans".
The feature of automatically matching URLs with controllers is nothing to laugh at or deny. You can say that the reason why Laravel is not designed this way is because of blabalbal... and the like, but you can't say that this requirement is weird.
As for imagining that others prefer the "?controller=xx&action=xxx" style, it is completely based on nothing.
Suppose I have to use Laravel one day and I want to write less rules, I plan to do this.
First make two files, router.custom.php and router.auto.php
auto is used to store automatically generated routing rules, and custom is used to store routing rules written by yourself. After all, it is difficult for automatic generation to cover all special needs
Then write comments on the controller that needs to automatically generate routing rules
Then write a script, use the reflection class to parse all the controller classes in the controller directory, generate routing rules based on the comments you defined, and put them in the auto file
In short, this is the general idea.
I also think it is quite troublesome to write a route in Laravel when writing a controller.
Laravel is not difficult to learn. If you learn symfony, you will know that laravel is not difficult. Moreover, there are many Chinese documents for laravel. Now there are many people using laravel in China, but I don’t know why I can’t search for laravel exchanges in qq. The group seems to have been blocked by Tencent (I found out after reading the comments that it was blocked by mistake).
I once suffered from the pitfalls of the default configuration mentioned by the poster. For example, it is difficult to distinguish get and post for the same URL using RESTful...