PHP code example of ez-it-solutions / laravel-init

1. Go to this page and download the library: Download ez-it-solutions/laravel-init library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ez-it-solutions / laravel-init example snippets


   'providers' => [
       // ...
       Ez_IT_Solutions\AppServe\AppServeServiceProvider::class,
       Ez_IT_Solutions\AppCleanup\AppCleanupServiceProvider::class,
       Ez_IT_Solutions\AppInit\AppInitServiceProvider::class,
       Ez_IT_Solutions\DatabaseTools\DatabaseToolsServiceProvider::class,
   ],
   



namespace Ez_IT_Solutions\AppInit;

use Illuminate\Support\ServiceProvider;
use Ez_IT_Solutions\AppInit\Commands\AppInit;
use Ez_IT_Solutions\AppInit\Commands\AppDeploy;
use Ez_IT_Solutions\AppInit\Commands\AppOptimize;
use Ez_IT_Solutions\AppInit\Commands\AppPrepare;
use Ez_IT_Solutions\AppInit\Commands\CheckRequirementsCommand;

class AppInitServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->commands([
                AppInit::class,
                AppDeploy::class,
                AppOptimize::class,
                AppPrepare::class,
                CheckRequirementsCommand::class,
            ]);
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // No additional services to register
    }
}



namespace Ez_IT_Solutions\AppCleanup;

use Illuminate\Support\ServiceProvider;
use Ez_IT_Solutions\AppCleanup\Commands\AppCleanup;

class AppCleanupServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->commands([
                AppCleanup::class,
            ]);
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // No additional services to register
    }
}



namespace Ez_IT_Solutions\DatabaseTools;

use Illuminate\Support\ServiceProvider;
use Ez_IT_Solutions\DatabaseTools\Commands\DatabaseInitCommand;
use Ez_IT_Solutions\DatabaseTools\Commands\MysqlExecCommand;

class DatabaseToolsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->commands([
                DatabaseInitCommand::class,
                MysqlExecCommand::class,
            ]);
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // No additional services to register
    }
}



namespace Ez_IT_Solutions\AppServe;

use Illuminate\Support\ServiceProvider;
use Ez_IT_Solutions\AppServe\Commands\AppServeCommand;

class AppServeServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->commands([
                AppServeCommand::class,
            ]);
        }
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // No additional services to register
    }
}

namespace Ez_IT_Solutions\AppServe\Commands;

protected $signature = 'app:serve 
    {--host=127.0.0.1 : The host address to serve the application on}
    {--start-port=8001 : The starting port number to try}
    {--max-attempts=10 : Maximum number of ports to try}
    {--no-open : Do not open the browser automatically}';

protected function openBrowser($url)
{
    if (PHP_OS_FAMILY === 'Windows') {
        // Use 'start /B' to start the process in the background without a new window
        shell_exec('start "" /B ' . escapeshellarg($url));
    } elseif (PHP_OS_FAMILY === 'Darwin') {
        // On macOS, use 'open' with the URL
        shell_exec('open ' . escapeshellarg($url));
    } else {
        // On Linux, use 'xdg-open' with the URL
        shell_exec('xdg-open ' . escapeshellarg($url) . ' > /dev/null 2>&1 &');
    }
}

protected $signature = 'your:serve {--host=127.0.0.1 : The host address to serve the application on}';
bash
# Prepare for development environment
php artisan app:prepare development

# Prepare for production environment
php artisan app:prepare production

# Options:
#   --clean             Remove unnecessary files
#   --permissions       Set appropriate file permissions
#   --optimize          Run optimization commands
bash
php artisan app:init
bash
# Create deployment package
php artisan app:deploy --prepare

# Set up after deployment
php artisan app:deploy --setup
bash
php artisan app:install-tailwindcss
bash
php artisan app:optimize
bash
php artisan app:cleanup
bash
php artisan app:status
bash
php artisan app:check-
bash
php artisan db:init
bash
php artisan db:backup
bash
php artisan mysql:exec --command="SHOW TABLES;"
bash
php artisan app:serve
bash
php artisan app:serve --https
bash
php artisan app:serve --env=testing
bash
php artisan app:serve --docroot=public_html
bash
php artisan app:serve --browser=chrome
bash
php artisan app:serve --qr
bash
php artisan app:serve --hosts=127.0.0.1,192.168.1.100
bash
php artisan app:serve --watch
php artisan app:serve --watch-dir=resources/views
bash
php artisan app:serve --metrics
bash
php artisan app:serve --api-mode