PHP code example of ez-it-solutions / app-serve

1. Go to this page and download the library: Download ez-it-solutions/app-serve 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 / app-serve example snippets




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}';

app-serve/
├── src/
│   ├── Commands/
│   │   └── AppServeCommand.php
│   └── AppServeServiceProvider.php
├── composer.json
├── LICENSE
└── README.md
bash
php artisan app:serve
bash
php artisan app:serve --host=192.168.1.100
bash
php artisan app:serve --start-port=3000 --max-attempts=5
bash
php artisan app:serve --no-open
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