Download .zip |
Info | Example | Videos | View files (21) | Download .zip | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 93 | All time: 9,449 This week: 319 |
Version | License | PHP version | Categories | |||
cymapgt-console 1.0.4 | BSD License | 5.4 | PHP 5, Console |
package for exposing PHP services via a console interface, providing build in authentication if needed
The console package allows other packages to implement an interface that allows them to provide command line functionality to their classes in with minimal duplication of code. A NetConsoleInterface aware class can be registered to the console API; which offers among other things automatic help generation as well as an authentication interface prior to accessing registered namespaces.
require "cymapgt/console" : "^1.0.0"
The package comes with two demo Classes that implement the NetConsoleInterface. See the files src/DemoApi.php and src/DemoRpi.php for template which you can use to implement your NetConsole class. Copy the files and customize as required.
The default NetConsole authentication comes with some assumptions:
1.You auth data store is a database, with a table named user; and fields for username and password
2.You have an active user named console in the datastore
If you adhere to the above, your console authentication will work out of the box (assuming as well that the NetworkBootstrap is properly configured).
If you would like to implement your own Authentication, replace the file src/helper/ConsoleCredentials.php and in it
1.Create a class named ConsoleCredentials
2.Creat a public static method named authenticate() that will implement your custom authentication logic
The core of NetConsole implements the NetConsoleInterface. There are a number of reserved keywords:
1.ADD COMMAND:
add serviceName serviceNamespace
COMMANDS AND SWITCHES:
COMMANDS
serviceName - The name of the service as registered in the console, or one of the sticky services.
serviceNamespace - The fully qualified namespace for the service being registered to the netconsole API
SWITCHES
None
EXAMPLE:
add bootstrap cymapgt\core\utility\bootstrap\console\BootstrapConsole;
2.HELP COMMAND:
help serviceName [-v="..."] [-m="..."]
COMMANDS AND SWITCHES:
COMMANDS
serviceName - The name of the service as registered in the console, or one of the sticky services.
SWITCHES
-v - The verbosity level of the help documentation
-m - Specifying a method name here will filter the help to provide only docs for that specific method
EXAMPLES
help bootstrap -m=config-all -v=3
help add
3.REMOVE COMMAND:
remove serviceName
COMMANDS AND SWITCHES:
COMMANDS
serviceName - The name of the service as registered in the console, or one of the sticky services.
SWITCHES
None
EXAMPLE:
remove bootstrap
4.QUIT COMMAND:
quit
COMMANDS AND SWITCHES:
COMMANDS
None
SWITCHES
None
EXAMPLE:
quit
5.CUSTOM COMMANDS:
Your PHP services functionality is exposed by implementing the NetConsoleInterface
After this implementation, you need to register your package with NetConsole by using the add command.
Successfully adding the package will expose all of the commands and switches you defined in the console configuration. The package can thus be used for managing tasks such as application installations within a controlled environment if you are distributing your proprietary logic.
It can also be used to quickly convert PHP services to console applications.
PHPUnit Tests are provided with the package
BSD 3-clause
Videos | ||
Files |
File | Role | Description | ||
---|---|---|---|---|
bin (2 files) | ||||
src (4 files, 4 directories) | ||||
tests (2 directories) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | bin |
File | Role | Description |
---|---|---|
netconsole | Data | Auxiliary data |
netconsole.php | Example | Example script |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
abstractclass (1 file) | ||||
config (2 files) | ||||
Exception (1 file) | ||||
helper (3 files) | ||||
ConsoleManager.php | Class | Class source | ||
DemoApi.php | Class | Class source | ||
DemoRpi.php | Class | Class source | ||
NetConsole.php | Class | Class source |
Files | / | src | / | config |
File | Role | Description |
---|---|---|
ConsoleConfig.php | Class | Class source |
NamedConstant.php | Aux. | Auxiliary script |
Files | / | src | / | helper |
File | Role | Description |
---|---|---|
ConsoleCredentials.php | Class | Class source |
ConsoleEcho.php | Class | Class source |
ConsoleRegister.php | Class | Class source |
Files | / | tests | / | files |
File | Role | Description |
---|---|---|
bootstrap.php | Aux. | Auxiliary script |
phpunit.xml | Data | Auxiliary data |
Files | / | tests | / | src |
File | Role | Description |
---|---|---|
ConsoleManagerTest.php | Class | Class source |
NetConsoleTest.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.