How to rename Http directory 'Controller' in Laravel

How to rename Http directory 'Controller' in Laravel



I am thinking of renaming app/Http directory name to my custom name. Like rename "Http to MyCustomName".



Default Laravel folder:
app/Http/Controllers



After renaming:
app/MyName/Controllers



Can we do that in Laravel?
If yes, then where should I change the namespace and all?





What's your main reason for wanting to change it?
– Ross Wilson
Aug 29 at 17:51




2 Answers
2



You have to change the $namespace inside the Providers/RouteServiceProvider.php so you could stay mention the controller in your routes using the relative format.


$namespace


Providers/RouteServiceProvider.php



Then execute the command :


composer dump-autoload





Already did it. But it won't work.
– webdev
Aug 29 at 8:13





Ok please explain more what you mean by it won't work.
– Zakaria Acharki
Aug 29 at 8:15





@webdev Did you change the namespaces in all the classes in that directory and then run composer dump-autoload?
– Ross Wilson
Aug 29 at 17:53


composer dump-autoload





It worked! Thanks. Forgot to fire command composer dump-autoload.
– webdev
Aug 31 at 6:23



Yes, you can. And you must change namespaces of the all classes which exists in Http folder. And change $namespace property in the RouteServiceProvider.


Http


$namespace


RouteServiceProvider



But this is not a good idea, because Http directory is one of the basic directories of Laravel.


Http






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)