Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

RhysLees/laravel-installer-plus

Repository files navigation

Laravel Installer Plus

License

This is a community project and not an official Laravel one

  • This is a cli tool for the installation of laravel.
  • It will install the laravel application and the packages you specify.

Built with Laravel Zero.


Requirements

IMPORTANT: This Package assumes that you have laravel-installer, composer and php installed globally.


Installation

$ composer global require rhyslees/laravel-installer-plus
$ laravel-installer-plus install

Your configuration is stored in $HOME/.laravel-installer-plus/config.json


Documentation


Options

All Laravel Installer options are included in Laravel Installer plus so you can optionally pass them.

    --dev : Create a development environment
    --git : Initialize a git repository
    --branch : Initialize the application with the given branch
    --github : Create a new repository on GitHub
    --organization : The GitHub under the given organization
    --jet : Installs the Laravel Jetstream scaffolding
    --stack : The Jetstream stack that should be installed
    --teams : Indicates whether Jetstream should be scaffolded with team support
    --prompt-jetstream : Issues a prompt to determine if Jetstream should be installed
    --force : Overwrite existing files

NOTE: If you use options such as --git for every appliction you can add them to laravel-options in the config and they will be appended to the command so you dont need to specifiy them manually (see example below).

"laravel-options": {
    "--branch": "green",
    "--git": true
},

Project Install Location

  • The location where the laravel application will be installed.

If you have a directory where all projects exist, you can set it install-location in $HOME/.laravel-installer-plus/config.json. This will then run the install commands to that directory no matter where you run the command from.

When changing this remember you only specify the path relative to your home directory.

macOS / GNU / Linux Distributions: $HOME/

For example if you use a folder named Projects in your home directory, you can set the install location to Projects.

"install-location": "Projects"

Leaving this option as an empty string will use the current directory.

NOTE: If you are unsure if you have set this correctly, you can check by running laravel-installer-plus location {name} which will output where it would install the application.


Packages to install

  • The packages that will be installed.
  • The composer and npm.
  • You can change this in the config.json file.
  • You need add packages to the packages array.
  • Specify the key of the package you want to install

Packages to install Example

"packages-to-install": {
    "composer": [
        "spatie-laravel-ray",
        "barryvdh-laravel-debugbar",
    ],
    "npm": [
        "laravel-echo",
        "pusher-js"
    ]
},

Packages

  • The package that can be installed.
  • You can change this in the config.json file.
  • The packages are installed in the order you specify.
  • You can install packages with both composer and npm.

Package Example

"packages": {
    "composer": [
        {
            "name": "Laravel Ray",
            "key": "spatie-laravel-ray",
            "commands": [
                "composer require spatie/laravel-ray",
                "php artisan ray:publish-config"
            ]
        }
    ],
    "npm": [
        {
            "name": "Laravel Echo",
            "key": "echo",
            "commands": [
                "npm i laravel-echo",
            ],

        }
    ]
},

Repositories

If you need to require a private package, first add the package to the packages->composer array. You can then add the repository to the repositories array.

"repositories": [
    {
        "key": "",
        "name": "",
        "type": "",
        "url": ""
    }
],

key must match the package key. name is the name of the package (see example below). type is the type of repository. url is the url of the repository.

With VCS:

"repositories": [
    {
        "key": "spatie-laravel-ray",
        "name": "laravel-ray",
        "type": "vcs",
        "url": "https://github.com/spatie/laravel-ray"
    }
],

With Path (symlink):

"repositories": [
    {
        "key": "spatie-laravel-ray",
        "name": "laravel-ray",
        "type": "path",
        "url": "../../Packages/spatie/laravel-ray"
    }
],

NOTE: when using path ensure the url is relative to your project directory.


Commands

  • The commands are executed in the order you specify.
  • You can execute commands with composer and npm.

You use use $name and $nameSnake variables in your commands which can be useful for example if you want to create a database.

"mysql -u root -e 'create database $nameSnake'"

which would become

"mysql -u root -e 'create database my_app'"

NOTE: If you wish to run sudo commands you will be prompted for your password at each command step i.e pre-install, post-install, pre-package, post-package.

Commands Example

"commands": {
    "composer": {
        "pre-install": [
            "sudo composer self-update",
            "composer cache-clear"
        ],
        "post-install": [
            "php artisan migrate:fresh --seed",
            "valet restart",
            "valet link",
            "valet secure",
        ],
        "pre-package": [
            "composer update",
        ],
        "post-package": [
            "composer dump-autoload",
        ],
    },
    "npm": {
        "pre-install": [
            "npm install -g npm@latest",
        ],
        "post-package": [
            "npm run dev",
        ],
    },
}

Pre Install

The commands that will be run before the installation of laravel.

IMPORTANT: Pre Install commands are run in the install-location not the application location.

Post Install

The commands that will be run after the installation of laravel.

Pre Package

The commands that will be run before the installation of packages.

Post Package

The commands that will be run after the installation of packages.


####TODO

  • Make it posible to install from current working directory.
  • Add support for manipluating files such as .env, app.css etc.
  • Move away from using laravel/installer to install laravel.

License

Laravel Installer Plus is an open-source software licensed under the MIT license.