PHP code example of tomatophp / console-helpers

1. Go to this page and download the library: Download tomatophp/console-helpers 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/ */

    

tomatophp / console-helpers example snippets


use TomatoPHP\ConsoleHelpers\Traits\RunCommand;

class MyCommand extends Command{
    use RunCommand;
    
    public function handle(){
       $this->phpCommand('echo "welcome";');
    }
}


use TomatoPHP\ConsoleHelpers\Traits\RunCommand;

class MyCommand extends Command{
    use RunCommand;
    
    public function handle(){
       $this->yarnCommand('echo "welcome";');
    }
}


use TomatoPHP\ConsoleHelpers\Traits\RunCommand;

class MyCommand extends Command{
    use RunCommand;
    
    public function handle(){
       $this->artisanCommand('migrate');
    }
}

use TomatoPHP\ConsoleHelpers\Traits\HandleStub;

class MyCommand extends Command{
    use HandleStub;
    
    public function handle(){
        $this->generateStubs(
            from: __DIR__ . "/stubs/SettingsClass.stub",
            to: "Modules/Base/Settings/MainSettings.php",
            replacements: [
                "settingName" => "site_url",
                "moduleName" => "Base",
                "settingField" => Str::lower("site_url")
            ],
            directory: [
                "Modules/Base/Settings/"
            ],
            append: false
        );
    }
}

use TomatoPHP\ConsoleHelpers\Traits\HandleModules;

class MyCommand extends Command{
    use HandleModules;
    
    public function handle(){
        $this->activeAllModules();
        $this->stopAllModules();
    }
}

$this->activeModule("Base");