Giter Site home page Giter Site logo

Comments (4)

DPr00f avatar DPr00f commented on May 5, 2024

I think L4 way is much more cleaner, and allows you to organize your app in a cleaner way, yes in L3 you could do 'auth@login', but you memorize that the first parameter is the Controller, in the L4 version you don't need to memorize anything, you just need to read and identify where is the controller and where is method.
I think L4 approach, to be more meaningful is good, you may write a little bit more of code, but you can read it as it was english.
Maybe they'll change it to L3 Routes, but i really doubt that.

from framework.

bencorlett avatar bencorlett commented on May 5, 2024

Much prefer L4's way of specifying controllers to respond a route. There is no convention anymore (which I'm stoked about) for naming of, well, any class in L4. This leads to huge flexibility.

If you require your app to have this logic, you could create a package and put it up on composer or you could simply edit a couple of files to manipulate the core to behave like you'd want. You could also do something like:

<?php

// in start.php
$app['router'] = $app->share(function($app) { return new MyCustomRouter($app) });

// in MyCustomRouter.php
class MyCustomRouter extends Illuminate\Routing\Router {

    protected function createControllerCallback($attribute)
    {
        list($controllerAlias, $method) = explode('@', $attribute);

        $actualController = ucfirst($controllerAlias).'Controller';

        return parent::createControllerCallback($actualController.'@'.$method);
    }

}

And vòila, you've got your app-specific controller assumptions and logic.

from framework.

niallobrien avatar niallobrien commented on May 5, 2024

I think I forgot to dump-autoload after renaming. Foo.PHP and classname Foo works fine.
However, a note to others, perhaps keeping Controller in the name is better. Yes, generating an URL isn't as clean (FooController@index) however, when you've lots of files open, it's a lot easier to know which tab is your controller! ;)

from framework.

robclancy avatar robclancy commented on May 5, 2024

In L4 you can actually name things any way you like as it isn't mapped that way, it uses composers autoloader which will map a file path to whatever class is used. So you could name your file snake_case_name.php and then the controller RandomController_Name and it would still work fine.

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.