简体   繁体   中英

Custom Laravel Directory Install With Composer

I was wondering if it was possible to create a custom laravel "template" with composer.

For example, I want to include in my composer's create-project laravel/laravel install these two extensions by default,
https://github.com/briannesbitt/Carbon
https://github.com/maxhoffmann/parsedown-laravel

or additional folders in the root directory so I don't have to re-create them each time.

I don't mean to ask how to install those ^ above,

but I mean to ask how to set it up so that when i run
composer create-project laravel/laravel projName
It automatically has those files/extensions/etc created and/or installed

Just add maxhoffmann/parsedown-laravel in your composer.json file:

"require": {
    "laravel/framework": "4.1.*", // version could be 4.2.*
    "maxhoffmann/parsedown-laravel": "dev-master"
},

The Carbon package is already avaiable with Laravel by default. Also in app/config/app.php add another entry in providers array like this ( Check details here ):

'providers' => array(
    // other entries...
    'MaxHoffmann\Parsedown\ParsedownServiceProvider'
),

Also add an entry in aliases array like this:

'aliases' => array(
    // other entries...
    'Markdown'        => 'MaxHoffmann\Parsedown\ParsedownFacade',
),

You said:

or additional folders in the root directory so I don't have to re-create them each time.

It doesn't make any sense, sorry!.

If I'm understanding you correctly, you can load custom libraries and have them autoloaded via composers "autoload" section. How you actually load the code into you project is up to you. git submodules is a good option. I'm not familiar with the Laravel directory structure so replace the paths to something that fits:

{
    "require": {
        // requires go here
    },
    "require-dev": {
        // require dev go here
    },
    "config": {
        "bin-dir": "bin/"
    },
    "autoload": {
        "psr-0" : {
            "Carbon": "src/lib/Carbon/src",
            "Carbon\\Test": "src/lib/Carbon/tests"
        }
    }
}

可能最好的方法是安装默认的Laravel,按需配置,然后将默认模板保存在github ...上,这样就可以执行git clone url_to_your_template_repository吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM