bear8421 / command-line-tool
Base Command Line Tool use Silly CLI micro-framework based on Symfony Console
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:project
Requires
- php: ^7.2 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- mnapoli/silly: ^1.7
- mnapoli/silly-php-di: ^1.0
Requires (Dev)
- fakerphp/faker: ^1.9
- nguyenanhung/database: ^3.0
- nguyenanhung/helpers: ^3.0
- nguyenanhung/monitor: ^3.0
- nguyenanhung/my-cache: ^3.0
- nguyenanhung/my-debug: ^3.0
- nguyenanhung/requests: ^3.0
- pheromone/phpcs-security-audit: ^2.0
- roave/security-advisories: dev-latest
Suggests
- ext-curl: Needs for support CURL
- ext-json: Needs for support JSON
- ext-simplexml: Needs for support SimpleXML
- ext-xml: Needs for support XML
- nguyenanhung/database: Needs for support Database
- nguyenanhung/monitor: Needs for support Monitoring Service
- nguyenanhung/my-cache: Needs for support Cache
- nguyenanhung/my-debug: Needs for support Logger
- nguyenanhung/requests: Needs for support Request use CURL
- pheromone/phpcs-security-audit: phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP coder
README
Base Command Line Tool use Silly CLI micro-framework based on Symfony Console
Donate Me
Buy me a coffee: https://paypal.me/nguyenanhung
Summary
Key | Value |
---|---|
Project | Start Project PHP CLI |
Framework | Silly CLI micro-framework |
GitHub | https://github.com/bear8421/command-line-tool |
Packagist | https://packagist.org/packages/bear8421/command-line-tool |
Install the Application
Run this command from the directory in which you want to install your new CLI micro-framework application.
composer create-project bear8421/command-line-tool [my-app-name]
or
php composer.phar create-project bear8421/command-line-tool [my-app-name]
Replace [my-app-name]
with the desired directory name for your new application.
Usage
Create TestCommand
in namespace Bear\App\Command
class TestCommand { public function __invoke($name, $upper, OutputInterface $output) { if ($name) { $text = 'Hello, Iam ' . $name; $output->writeln("Bear"); } else { $text = 'Hello, Iam.' . $this->son(); } if ($upper) { $text = strtoupper($text); } $output->writeln($text); } protected function son(): string { return "Bear"; } }
And declare Command in Bear
in bear
file in root folder
#!/usr/bin/env php <?php // Register Application Space define('BEAR', $_SERVER['BEAR_ENV'] ?? 'production'); // Includes Composer Vendor Packages require_once __DIR__ . '/vendor/autoload.php'; use Silly\Edition\PhpDi\Application; $app = new Application(); // Routes list Command $app->command('greet [name] [--upper]', 'Bear\App\Command\TestCommand'); try { $app->run(); } catch (Exception $e) { echo $e->getMessage(); }
Running the application is the same as running any other Symfony Console application:
$ php bear greet
Hello
$ php bear greet john --yell
HELLO JOHN
$ php bear greet --yell john
HELLO JOHN
Silly\Application
extends Symfony\Console\Application
and can be used wherever Symfony's Application can.
Documentation
Also see Official Document here: https://github.com/mnapoli/silly
Contact
If any question & request, please contact following information
Name | Skype | ||
---|---|---|---|
Hung Nguyen | dev@nguyenanhung.com | nguyenanhung5891 | @nguyenanhung |
From Hanoi with Love <3