Standalone command app below works fine on its own when I call: php console.php say:hello MyName
The question is at the bottom.
/var/www/html/local/test-app/composer.json
{
"name": "my/test-package",
"description": "......",
"type": "library",
"version": "1.0.0",
"autoload": {
"psr-0": {"": ""}
},
"require": {
"symfony/console": "2.*"
},
"minimum-stability": "stable"
}
/var/www/html/local/test-app/Command/HelloCommand.php
<?php
namespace Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class HelloCommand extends Command
{
protected function configure()
{
$this
->setName('say:hello')
->setDescription('Say hello to someone')
->addArgument(
'name',
InputArgument::OPTIONAL,
'Who do you want to say hello?'
);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
$hello = $name ? 'Hello '.$name : 'Hello';
$output->writeln($hello);
}
}
/var/www/html/local/test-app/console.php
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
use Command\HelloCommand;
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new HelloCommand());
$application->run();
QUESTION
When I include standalone package in my main project's composer.json, composer installs everything but when I call php console.php say:hello MyName
I get Could not open input file: console.php
error. Obviously I have to create a symlink in bin
directory like behat, phing, phpspec, doctrine etc. but how?
my main project's composer json
"require": {
"my/test-package": "dev-master"
},
I've checked:
- The Console Component
- step-by-step how to use a single component in your project
- Symfony2 Components as standalone Packages
- https://github.com/exu/symfony2-console-standalone
- Command line PHP using Symfony Console
So on....
console.php
have incorrect permissions. – malcolm$ php DoesNotExist.php
outputsCould not open input file: DoesNotExist.php
. Otherwise, check to make sureconsole.php
has read permissions. – HPierce