Giter Site home page Giter Site logo

ghostconcepts / laravel-software-install Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unicodeveloper/laravel-software-install

0.0 0.0 0.0 46 KB

Laravel Software Install Script Template - Most especially awesome for Open Source Projects

JavaScript 0.69% PHP 98.46% CSS 0.10% ApacheConf 0.75%

laravel-software-install's Introduction

Laravel Software Install Script Template/Process

Many developers find it kinda confusing at first on how to go about creating install scripts for clients or users of open source projects. This is a simple template/step-by-step process to help you accomplish that. You can fork, contribute to it or just copy the template/process into your app and improve on it based on your specific need.

It has to do with creating a custom artisan command. If you are not sure how to go about that, please check this comprehensive blog post

Stey by Step Process

  1. Open your Terminal and Run the command:
    php artisan make:console Install

This creates a file called Install.php in the app/Console/Commands directory.

  1. Open the file Install.php and dump this:
<?php

namespace App\Console\Commands;

use DB;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class Install extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'software:install';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Install this software without issues, Thanks!';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        try {
            DB::connection();
        } catch (Exception $e) {
            $this->error('Unable to connect to database.');
            $this->error('Please fill valid database credentials into .env and rerun this command.');
            return;
        }

        $this->comment('Attempting to install Software - 1.0.0');

        if (! env('APP_KEY')) {
            $this->info('Generating app key');
            Artisan::call('key:generate');
        } else {
            $this->comment('App key exists -- skipping...');
        }

        $this->info('Migrating database...');

        Artisan::call('migrate', ['--force' => true]);

        $this->comment('Database Migrated Successfully...');

        $this->info('Seeding DB data...');

        Artisan::call('db:seed', ['--force' => true]);

        $this->comment('Database Seeded Successfully...');
        $this->comment('Successfully Installed! You can now run the software');
    }
}

By adding this, a user can now run php artisan software:install from the terminal.

The code goes from:

  • ensuring the user has a database on standby with valid database credentials
  • to generating app key
  • to Migrating the database scripts ( migration files)
  • to seeding the database with data ( ensure you have the seeder classes all set up, an example is in this repo)

This process captures the basic install process every user usually goes through in just one script, you can definitely add/improve on it.

Example User Install Instruction to be given by Developer

laravel-software-install's People

Contributors

unicodeveloper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.