AydenWH's avatar

Use Composer create own project template

Hello everyone,

May I know how to use Composer to create my own Laravel project template?

Example, I have created a Laravel template and preset some features into Laravel project for future use.

So, next time I could just key in composer create-project --prefer-dist mylaravel/laravel preset-template

Thanks.

0 likes
4 replies
bobbybouwmann's avatar
Level 88

Well your project works like a package with dependencies. So you can simply create a new composer project and you are done ;)

Follow the submit process here: https://packagist.org/packages/submit

Note your project must be on Github for this, since composer is focused on OpenSource packages

1 like
AydenWH's avatar

@bobbybouwmann

https://packagist.org/packages/wh-laravel/laravel5.4-template

May I know why I get this error when I type composer require wh-laravel/laravel5.4-template

[InvalidArgumentException]                                                    
  Could not find package wh-laravel/laravel5.4-template at any version for your minimum-stability (stable). Check the
   package spelling or your minimum-stability

This is my composer.json

{
    "name": "wh-laravel/laravel5.4-template",
    "description": "The Laravel Template for Own Development.",
    "keywords": ["framework", "laravel", "template"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.4.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true
    }
}
bobbybouwmann's avatar

Yeah, you either need to tag your package on Github or change the minimum-stability flag in your composer.json file

Please or to participate in this conversation.