php - Laravel blade dynamic directory -


i working on modular structure such below

modules     module         controllers         models         views 

however struggling figure out how load views dynamic directory, instance there 20 different modules each 1 loading views own directory, possible way blade renders templates @ moment?

although you're asking "modular" behaviour, mentioned in comments may want consider service providers , packages instead. laravel more service-oriented architecture. referenced can learn more soa on wikipedia.

imho modules old practice , inflexible when comes dependencies - when 2 packages need override same dependency in package not know of each other - takes precedence?

creating package

in order started, quickest way create own package have it's own repository (which assume git , local repository - can anywhere however, private repository on github, bitbucket or own private server).

first create repository, assume you're doing locally inside /users/developer/projects.

$ cd ~/projects $ git init blog 

as per composer documentation need composer config in order application update package in vendor.

you want create inside blog repository has been created (file: composer.json).

{     "name": "yourcompany/blog",     "description": "description of package is.",     "version": "1.0.0-dev",     "authors": [         {             "name": "developer name",             "email": "developer@company",             "role": "software develper"         }     ],     "require": {         "php": ">=5.5.9",     },     "autoload": {         "psr-4": {             "company\\blog\\": "src/"         }     },     "minimum-stability": "dev" } 

so package structure should following:

blog/ ├── database/     ├── migrations/     ├── seeds/ ├── resources/     ├── assets/     ├── lang/     ├── views/ ├── src/     ├── blogserviceprovider.php ├── composer.json ├── readme.md 

the mandatory files/directories here composer.json file , src directory.

if refer laravel documentation - package development learn how set-up service providers, route service providers , make package publishable. you're trying achieve?

when publish content application, allows override views in application , keep package generic without hacking things together.

register package

you want register package application, editing application/project composer.json.

as packages private need tell composer repositories are. after "type": "project", config need define repositories; like:

"repositories": [     {         "type": "vcs",         "url": "/users/developer/projects/blog"     } ] 

you need inform composer require blog package, repositories defines location when composer fails discover on packagist.

"require-dev": {     "fzaninotto/faker": "~1.4",     "mockery/mockery": "0.9.*",     "phpunit/phpunit": "~4.0",     "phpspec/phpspec": "~2.1",     "vendor/blog": "dev-master" }, 

however, once you've completed development on package should move "require" list , not "require-dev" replacing version:

"require": {     "php": ">=5.5.9",     "laravel/framework": "5.1.*",     "vendor/blog": "1.0.*" }, 

code examples

you can review laravel source in order build package.


to conclude; package functions module except there many more advantages packages of listed part of solid pattern , there learning curve it.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -