Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

milenial's avatar

Implicit Controllers - Laravel 5.4

When you guys from Laravel will back with Route::controller() ?

This is kind absurd.

We have a full ERP with Route::controller(Controller) and is almost insane to redo all this code expliciting all the routes.

Also, we have a lot Ajaxes that use "getMethod and postMethod" combined, for exemple.

getMethod returns the HTML structure of a table (datatable for instance), and the postMethod returns JSON part with data.

anyFunction () { isPost( json ) else { html ); }

You should put it back, it gives a lot of flexibility.

0 likes
24 replies
SaeedPrez's avatar

You can write something yourself to mimic that functionality if you need it so bad or do a search, maybe there is a package that does that.. or perhaps you can create a package and share it with others who have problems writing a few lines of code.

Also, I doubt Taylor visits Laracasts very often. You can barely reach Jeffrey Way here and he owns this site. If you want to reach him, Twitter or Github would probably be a better channel to communicate but I highly doubt you'll succeed to convince him to bring it back as an included feature, it was removed in 5.2 (if I'm not mistaking) for a reason.

2 likes
milenial's avatar

This is the kind of change that hurts many people.

And having both ways to work don't harm the framework itself.

Also, it's weird to write all routes and have another method to "Speed up large routes files". Doesn't seem smart.

1 like
milenial's avatar

SaeedPrez, Before i wrote this topic, I've looked all this stuff and other options.

They seem to me a quick fix, a "easy way", not a good way.

The goal of this topic is to register my dissatisfaction with this change.

My project has more than 6k files (about 13k including laravel stuff), almost 600 mysql tables and its very organized.

My Laravel 4.2 project use many things that Laracasts took two years to mention, like: multi auth, mutli databases, repository patterns.

Also, I have all the structure need: Power Edge servers runing Xenserver, Load Balancing, NFS shares, etc.

So, I'm not a newbie and I'm not doing a Blog to my School.

Thanks anyway.

SaeedPrez's avatar

@milenial now it makes even less sense to me..

You are a seasoned developer / Laravel developer, so in my head I'm thinking..

  • It shouldn't be hard or even take long for you to take the code you need from i.e. Laravel 5.1 and create a package for your needs, maybe even share it with others

  • Or even write a similar functionality for your project

  • Or like you said, you've already looked at the options, then why is it a quick fix or "easy way" to use a package that offers the functionality that you want? Whole Laravel is bunch of packages but adding another package is suddenly not a good way?

  • You should understand why Route::controller() was deprecated

1 like
milenial's avatar

@SaeedPrez I understand why it uas deprecated, but i don't agree. I think both options should exist.

Imagine if PHP itself, or maybe your prefered Linux distro change vital parts in about 6-12 months.

Laravel 5.1 was released in July/2016 and this kind of thing changed in less than 1 year.

These kind of change don't take in account already running projects, their impacts, the cost of rebuild and re-test.

Now i will have to put someone to redo a thing that's working, just because Laravel thinks that a "pretty code" values more than a business need.

SaeedPrez's avatar

@milenial

Laravel 5.1 still has Route:controller() (link to Github), it was deprecated in Laravel 5.2.

I understand in some unique cases it might actually be useful, that's probably why it was added to start with but it really should have been a package from the start and not a standard function.

Jaytee's avatar

All this time bitching about it long after it's gone and you could of came up with a solution.......

Shit happens, things change, you work around it. Simple.

Now i will have to put someone to redo a thing that's working, just because Laravel thinks that a "pretty code" values more than a business need.

Going on like you paid to use Laravel. You've had plenty of time to come up with an alternative since it was deprecated.

Jesus. Yo @SaeedPrez what you up to? haha

1 like
Snapey's avatar

Or you could cut bitching and stay on the same version. No one is forcing you to upgrade.

1 like
milenial's avatar

@Jaytee and @Snapey your anwser is the reason I rarely participate on foruns.

If you are not worried about a framework (or any plataform) that change it's methods dramatically every new version - in instance, every four months.

Then you must be rich or have all time in the world to refactor things.

Or do like you said, @Snapey - don't upgrade anything and stay in the past forever - like a kid answer.

Theres new features i want to use, but i don't want to break all the code.

For example, i migrated from PHP 5.5 , to 5.6 then 7.0 without any major problems.

That's not true for Laravel, as I'm seeing now, after 2 years, that backward compatibility seems to not be a concern.

What to expect for the future? LV 5.6? 5.7? Refactor everything again?

"things change, get used to it"... that's not how a serious plataform should work.

Do you value your time? Do you run a company or you are an employee? It's a retorical question.

Good night.

Jaytee's avatar

@Snapey and I can't be the reason that you've only ever posted two topics in 9 months. Let's just get that one off the plate. You posted this topic without being polite pretty much.

You said @Snapey responded with a "kid answer". I'll let Snapey respond to that one, i'm sure he'll be thrilled.

You would rather sit here and talk about how it's absurd that it was removed, nearly a year since there was a warning it was going to be deprecated.

What is so hard about changing your application for the better? Oh "because your application is large". So? I dedicate time for upgrades if/when i need to, that may be different for you but there's no point complaining about it. You have heaps of solutions, not upgrading, find someone to do it, dedicate time for someone else to do it.

Explicit routing is a lot better.

When you started using Laravel, you would of known that updates would happen and things would change

Good morning.

SaeedPrez's avatar

I guess the sum of this discussion is what goes around comes around.

Hey @Jaytee ☺ Not much, working as usual, about to release hopefully next week .. how about you?

Jaytee's avatar

@SaeedPrez Nothing much. I'm into Day 3 of cutting down coffee. 3 cups a day or 8 cups as a normal sized cup lol. Massive headaches as you'd expect. Starting second and final semester of my Diploma in a week haha. What's your project that you're releasing?

SaeedPrez's avatar

Hey @usman ☺ how are you doing?

@Jaytee ah man, I've been there, those headaches are though but it'll get better. Awesome then, one down, one to go ☺ What are you studying? The project is a headless CMS for my new company, hopefully a quick way to generate revenue so I can focus on bigger plans.

Jaytee's avatar

@SaeedPrez We hijacked this thread coz' we're BAWSS haha. Yeah usually i have one cup to every 45mins to an hour. My cup is equal to 2.6 regular cups so it's a big hit for me. Water isn't so bad but then again, it is lemon and lime flavoured haha. It's just the headaches killing me. Felt fresh as on day one, feel like death now, time for the withdrawal symptoms to fuck off i reckon ;)

I'm studying a Web Development diploma, there wasn't really much of a path for me to take that interested me. The options were, IT Support, Networking or Web Development. The course is shite to be honest, the first semester was all about html and css with a little bit of python programming (that was aight). This semester involves databases which is no doubt going to be boring. I have multiple early starts for my schedule too which sucks because i can't even wake up early if i wanted to.

Wow, this paragraph is huge. I've never heard of a "headless" CMS, what is that? At least you're close to releasing your project, i keep changing mine around because i'm OCD when it comes to how my project structure looks haha.

SaeedPrez's avatar

@Jaytee

It's tough to cut down as much as you've done at once, it might be quicker though. What I did was I went down gradually, i.e. from 10 cups to 8 for a few days,then to 6, to 4, etc. But even today at 2-3 cups, if I don't get my caffeine, I will get headache around 3-4 pm and I usually never have headaches.

In my experience, school is usually pretty bad for web development, especially for people who have the prior passion/knowledge. You'll learn 10x more on your own and on your non-school time. With that said, it's always good to have a diploma, it shows you have the discipline to commit and finish something, it might also give you a better starting salary and those contacts you make in school can lead to big things in the future.

Headless CMS is.. Imagine something like WordPress but the control panel and website are separate. Basically, the website gets the data via API instead of being integrated into the control panel.

Don't even mention OCD, I'm ashamed to say this is the 4th time I'm rebuilding this project from ground up :( but this time I decided I would release it quick. Also thanks to Adam Wathan's TDD course, I learned to ignore (until a later version) all unnecessary features I spent weeks on in previous versions.

Snapey's avatar

I met someone in the elevator who was drinking coffee and complaining about how coffee made him nervous. I said why don't you quit drinking coffee. He said, "because if I didn't have the shakes I wouldn't get any exercise at all."

1 like
SaeedPrez's avatar

Haha, we are truly addicted to being addicted ☺

bonifazzy's avatar

Hi all! There is my workaround. What do you think about it? Works good in first steps. Request is passing to controller successfully. If there is argument like "id" after actionName/ it will be passed as first argument and Request object as second. Otherwise first and only parameter will be Request object. It makes controller just a little slimmer

Route::any('/{controller?}/{action?}/{arg?}', function ($controllerName = 'home', $actionName = 'index', $arg = null, Request $request) {
    $app = app();
    $cameledController = ucfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $controllerName))));
    $cameledAction = ucfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $actionName))));
    
    try{
        $controller = $app->make(sprintf('\App\Http\Controllers\%sController', $cameledController));
        return $controller->callAction($cameledAction, array($arg ?: $request, $request));
    } catch(Exception $e) {
        if ($e instanceof ReflectionException || $e instanceof BadMethodCallException) {
           abort(404);
        } else {
            throw $e;
        }
    }
});
Oilop9000's avatar

@milenial I solved it, thanks to the contribution of @SaeedPrez, I installed https://github.com/themsaid/laravel-routes-publisher, copied my old routes to the path this library needs and proved, in my case I had to comment a line because it was giving me errors. I edited yourprojectroot/vendor/themsaid/laravel-routes-publisher/src/RoutesPublisherCommand.php file, method getUri and commented out this line:

$this->getWildcards($routable)

Worked good, it also comments "translated routes"

Hope this helps.

Please or to participate in this conversation.