Where is laravel elegance, please?

Source: Internet
Author: User
Keywords Laravel composer
All said Laravel elegant, through the use of these days I found the wireless egg pain, full of anti-human, inhuman, is not the programmer can not have user experience, each plus a controller to add a route. Let's talk about routing first, the rest of the talk, his elegance in where please Daniel pointing.
Please give an example of Laravel strong, do not always say, laravel more cattle, composer how good, concrete fortunately where. For example, from a project point of view, in the specific implementation of a function, the use of what functions, the advantages of these formulations, as well as the maintenance of late.

Reply content:

Look at the document to know, in line with the human thinking of the way to write code. I used it to write the project, and later the company's iOS itself was changing the code. He doesn't have PHP, of course it doesn't change much.

In fact, there will be a problem: PHP is not familiar with the document to see the time you do not understand, and then say it is not good, so for the novice, it is not enough to fool the document, not like the domestic framework as a fool to teach you step by step how to write. hahaha haha ...
I'll talk about what you call the anti-human route mechanism.
I don't know what way to be more elegant than a manual way to mapping paths and behaviors.

As you mean, the ideal state is to add a controller to define an action to automatically mapping into the route. Yes, this is for writing simple crud is labor-saving Ah, but, to know that this lazy is not called elegance. You would say that the framework is to save the work of Ah, lazy what is wrong? You're wrong, the framework is used to make the project more elegant, not lazy.

Then I say the route is the elegance of your own manual configuration.

1, you can write a set of automatic controller and route,mapping of the small module, yes, you can write it yourself, because the route file is a php script file, you can call anything you want. Then, you want to lazy things, very easy to solve yourself.

2, callback, reasonable use of good callback characteristics, can play an infinite possibility.
3, routes.php file under the appropriate management, is a good research code of the entrance. You can easily find the controller or callback that corresponds to the URL. Clean at a glance, this is called elegance.


Finish the route said the whole, the bottom with the symfony2 of those things, what things to use the composer configuration, do not use it and do not need to use it. Then the elegant place is coming, ORM module I think with the awkward, then I do not have to drink bai ... HTTP with the awkward, it will not be bai ... Write it all by yourself. This is elegant, low-coupling. The good frame is the feeling of this kind, the whim.

And then spit it out, some not elegant frame ....

$_c and C ()

I'm not going to say much else. With the use of more advanced tools and ideas on the market so many frameworks, are very characteristic. "Elegance" was left to no one. Xie invited, Laravel the concept of more emphasis is Artisan, is the craftsman, craftsman's craftmanship that must be elegant, exquisite. So the so-called elegance, refers to the code is neat, easy to read and easy to manage;

First of all, easy to read, if you are familiar with English, you will gradually know that Taylor is a very high level of language people, laravel this word itself sounds like a very sexy name.
The so-called legibility, is that you can know the meaning of the code, without reading the comments, the code is very thin reusability is very high;

Code confusion can easily occur in the controller section, looking at an example, it is simple to get some data from the homepage:

Public Function Index (){$categories = [' novice ', ' instance ', ' plugin ', ' advanced '];$posts = post::with (' category ')->wherehas (' Category ', function ($q) use ($categories) {$q->wherein (' name ', $categories); })->orderby (' Created_at ', ' desc ')->simplepaginate (7);$tags = Tag::all ();   $most _read = Post::orderby (' clicks ', ' desc ')->with (' category ')->take (5)->get ();   $feature _ids = Settings::get (' features ');foreach ($feature _ids as $key = + $val) {$feature _posts[$key]=post::findorfail ($val);        }return view (' Front.index ', compact (' posts ', ' tags ', ' most_read ', ' feature_posts '));    }
Don't say anything else, first say the route. Do not know which version you use, Laravel 4.*? Have you tried group, before and after filter? Laravel 5? Try middleware? Is there any use for the restful? Not to mention how easy it is to use the route to get SEO.

Composer How to use it, not to mention, easy to manage, easy to expand, I do not know that composer can actually be so spit groove. Alas, I used a lot of frameworks, in the end, I was deeply disillusioned, directly with the PHP Echo statement is the most elegant. Simplicity is beauty! Many frameworks are over-engineered. It's a sad frame. I deeply feel the malicious contrast of this framework to the novice Phalcon see Laravel, did not find any elegant, cumbersome, low performance, not suitable for high-traffic enterprise-class applications. Why do I think the main point of the place, I feel very human, very easy to understand it.

Maintenance also have to say very good change ...

is not the laravel of a planet.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.