PHP 클래스 Silly\Application

저자: Matthieu Napoli ([email protected])
상속: extends Symfony\Component\Console\Application
파일 보기 프로젝트 열기: mnapoli/silly 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( $name = 'UNKNOWN', $version = 'UNKNOWN' )
command ( string $expression, callable | string | array $callable, array $aliases = [] ) : Command Define a CLI command using a string expression and a callable.
getContainer ( ) : Interop\Container\ContainerInterface | null Returns the container that has been configured, or null.
getInvoker ( ) : Invoker\InvokerInterface
runCommand ( string $command, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer Helper to run a sub-command from a command.
setInvoker ( Invoker\InvokerInterface $invoker )
useContainer ( Interop\Container\ContainerInterface $container, boolean $injectByTypeHint = false, boolean $injectByParameterName = false ) Set up the application to use a container to resolve callables.

비공개 메소드들

메소드 설명
assertCallableIsValid ( $callable )
createCommand ( $expression, callable $callable )
createParameterResolver ( ) : ParameterResolver Create the default parameter resolver.
defaultsViaReflection ( $command, $callable )
isStaticCallToNonStaticMethod ( mixed $callable ) : boolean Check if the callable represents a static call to a non-static method.

메소드 상세

__construct() 공개 메소드

public __construct ( $name = 'UNKNOWN', $version = 'UNKNOWN' )

command() 공개 메소드

Define a CLI command using a string expression and a callable.
public command ( string $expression, callable | string | array $callable, array $aliases = [] ) : Command
$expression string Defines the arguments and options of the command.
$callable callable | string | array Called when the command is called. When using a container, this can be a "pseudo-callable" i.e. the name of the container entry to invoke.
$aliases array An array of aliases for the command.
리턴 Silly\Command\Command

getContainer() 공개 메소드

Returns the container that has been configured, or null.
public getContainer ( ) : Interop\Container\ContainerInterface | null
리턴 Interop\Container\ContainerInterface | null

getInvoker() 공개 메소드

public getInvoker ( ) : Invoker\InvokerInterface
리턴 Invoker\InvokerInterface

runCommand() 공개 메소드

Helper to run a sub-command from a command.
public runCommand ( string $command, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$command string Command that should be run.
$output Symfony\Component\Console\Output\OutputInterface The output to use. If not provided, the output will be silenced.
리턴 integer 0 if everything went fine, or an error code

setInvoker() 공개 메소드

public setInvoker ( Invoker\InvokerInterface $invoker )
$invoker Invoker\InvokerInterface

useContainer() 공개 메소드

Only commands that are *not* PHP callables will be fetched from the container. Commands that are PHP callables are not affected (which is what we want). *Optionally*, you can also enable dependency injection in the callable parameters: $application->command('greet', function (Psr\Log\LoggerInterface $logger) { $logger->info('I am greeting'); }); Set $injectByTypeHint to true to make Silly fetch container entries by their type-hint, i.e. call $container->get('Psr\Log\LoggerInterface'). Set $injectByParameterName to true to make Silly fetch container entries by the parameter name, i.e. call $container->get('logger'). If you set both to true, it will first look using the type-hint, then using the parameter name. In case of conflict with a command parameters, the command parameter is injected in priority over dependency injection.
public useContainer ( Interop\Container\ContainerInterface $container, boolean $injectByTypeHint = false, boolean $injectByParameterName = false )
$container Interop\Container\ContainerInterface Container implementing container-interop
$injectByTypeHint boolean
$injectByParameterName boolean