yeriomin / console-app
A skeleton PHP console app with helpers for logging, running in a single instance, console input parameters.
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 3
Open Issues: 0
pkg:composer/yeriomin/console-app
Requires
- php: >=5.3.0
- caseyamcl/configula: ~2.3
- monolog/monolog: >=1.8.0
- yeriomin/getopt: >=1.0
This package is not auto-updated.
Last update: 2025-10-21 09:06:39 UTC
README
A skeleton PHP console app.
Usage
Install console-app as a dependency
$ composer require yeriomin/console-app
Extend \Yeriomin\ConsoleApp\ConsoelApp class and implement the run() method.
<?php class MyConsoleApp extends \Yeriomin\ConsoleApp\ConsoelApp { public function run() { $this->logger->info('Hi'); } }
Features
- Handles configuration files. Tries to read
./config.iniby default. - Handles console arguments. Extend
getGetopt()method to add your options. - Checks if another instance of the same script is running. Can be disabled in config.
- Checks if script is running in the console. Fails otherwise. Can be disabled in config.
- Inits monolog logger.
- Uses error and signal handlers to let you see that very important last message in the log.
Configuration
By default the following configuration options are supported:
consoleOnlyLet the script run only in console, not in browser. True by default.oneInstanceOnlyLet only one instance of the script be running at any time. True by default.logDirDirectory to put the log file to. Defaults to system temporary directory.logFileA specific file path for the log. If none provided/tmp/<script-class-name>.logis used.lockDirDirectory to put the lock file to. Defaults to system temporary directory.lockFileA specific file path for the lock file. If none provided/tmp/<script-class-name>.lockis used.
Console arguments
Two console options are supported by default:
-h|--helpShows usage message. It will include options you add.-c|--configPath to configuration file. Defaults to./config.ini