Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Can I change folder structure

Tags:

php

laravel

Standard Laravel structure is

app
---http
------Controllers
---------MyComponentController
---Models
------MyComponentModel
---database
------MyComponentnMigration

I wonder if there is the chance to change the folder structure to:

app
---MyComponent // kind of a package that holds all mandatory elements 
------Controllers
---------Controller
------Models
---------Model
------database
---------Migration

as it would make much more sense.

update

**why does people vote it down ? it is a serious question, a model has a dependency to a migration. so if you want to use the model in another project you have to search the migration in the project and all other relevant items that has a connection with it. if all mandatory files would be structured under one parent node it would be just a copy and paste.

It would be at least honest to understand why those down voters think this isn't a good idea **

like image 467
user7646471 Avatar asked Oct 18 '25 16:10

user7646471


1 Answers

Yes you can, actually we already did what you're thinking. We create a separate Folder and inside of it Models, Controllers, Requests , Views, Routes You just need to update the RouteProviders to rellocate your Controllers by modifying the namespace and for the Views. you just need to update via config folder .

like image 81
Kenneth Sunday Avatar answered Oct 21 '25 04:10

Kenneth Sunday



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!