php - Best practice to separate Backend / Frontend with single Laravel4 installation? -


i hear tips got real experience folder structure worked with.

coming codeigniter, i'm trying figure out best way create backend (cms) , frontend (frontpage) ?

here couple app structures want critics on, considering actual version of laravel 4.1.28.

structure 1

webapp     backend         app/         bower_components/         local_components/         node_modules/         public/         vendor/         artisan.php         composer.json         composer.lock         contributing.md         gruntfile.js         package.json         phpunit.xml         readme.md         server.php     frontend         app/         bower_components/         local_components/         node_modules/         public/         vendor/         artisan.php         composer.json         composer.lock         contributing.md         gruntfile.js         package.json         phpunit.xml         readme.md         server.php 

structure 2

webapp     app/         bootstrap/         commands/         config/         controllers/         ...         views/         filters.php         routes.php     cms/         bootstrap/         commands/         config/         controllers/         ...         views/         filters.php         routes.php     bower_components/     local_components/     node_modules/     public/         // public mywebapp.dev         ...         index.php     sub/backend     // public backend.mywebapp.dev         ...         index.php     vendor/     ...     server.php 

structure 3

webapp     app/         controllers/             backend/                 backendcontroller.php             frontend/                 frontendcontroller.php             basecontroller.php         models/             backend/                 backendmodel.php             frontend/                 frontendmodel.php             basemodel.php         views/             backend/                 layout.blade.php             frontend/                 layout.blade.php     bootstrap/     bower_components/     local_components/     public/         assets/             backend/                 js/                 css/             frontend/                 js/                 css/         index.php     vendor/     server.php 

also, if have own app structure, welcome share it.

this personal preference type of scenario , there no real correct answer works in different ways.

i tend similar to:

app     namespace // custom namespace, company affinitycloud. load in composer.json using psr-4 autoloading.         controllers // remove controllers folder initial app/controllers location , create new 1 in namespace, moving basecontroller.php file here too.             admin // here go admin/cms controllers             frontend // here go frontend controllers         exceptions         filters         handlers         models // same models folder controllers folder, making sure base.php model file in there. you'll need remember remove references old models , controllers folder app/start/global.php too, remove these references composer.json classmap.         presenters         repositories         services         utilities         validators 

i split frontend , backend assets under public/assets in separate locations have done above.

again, how others have cleaner solutions or different ways of working. say, it's personal thing.

i find enough separation , organisation purposes.

one other thing keep in mind if have generic code work on it's own outside of laravel, perhaps should consider creating separate composer package it.


Comments