contao / standard-edition

[DEPRECATED] Do not use anymore!
33 stars 8 forks source link

Installation broken via composer create-project #2

Closed dtomasi closed 9 years ago

dtomasi commented 9 years ago

A few days ago i was able to install contao/standard-edition via php composer.phar create-project contao/standard-edition contao4 @dev. After upload_path was added to parameters.yml this doesn´t work anymore.

  [InvalidArgumentException]                                               
  The "/private/var/www/standard-edition/files" directory does not exist.
leofeyer commented 9 years ago

We should run the Incenteev script handler at the end (or our handlers first).

dtomasi commented 9 years ago

I tried a few different orders, but it´s still not working.

If parameters.yml does not exist when Contao\CoreBundle\Composer\ScriptHandler::addDirectories is called, it will throw an Exception as well.

I think this happens because Contao\CoreBundle\Command\InstallCommand is a ContainerAwareCommand and uses parameters. So at this point Symfony will load config.yml which tries to import the non existing parameters.yml on top.

leofeyer commented 9 years ago

I have adjusted the order of the Composer script handlers in e8e64c133525811231d48bb7513b149ad70c06d6. Together with contao/core-bundle@f02f9ac8faf14b4f4c1433fbe0fe4b813e5d6b54 this should solve the issue. Can you please confirm?

dtomasi commented 9 years ago

Looks like the ContainerAwareCommand wasn´t the problem. There is still a RuntimeException.

composer create-project contao/standard-edition contao4 @dev -vvv


  [RuntimeException]                                             
  An error occurred while executing the contao:install command.  

Exception trace:
 () at /private/var/www/d.tomasi/contao4/vendor/contao/core-bundle/src/Composer/ScriptHandler.php:64
 Contao\CoreBundle\Composer\ScriptHandler::executeCommand() at /private/var/www/d.tomasi/contao4/vendor/contao/core-bundle/src/Composer/ScriptHandler.php:31
 Contao\CoreBundle\Composer\ScriptHandler::addDirectories() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:198
 Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:166
 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:91
 Composer\EventDispatcher\EventDispatcher->dispatchScript() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/Installer.php:336
 Composer\Installer->run() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/Command/CreateProjectCommand.php:173
 Composer\Command\CreateProjectCommand->installProject() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/Command/CreateProjectCommand.php:131
 Composer\Command\CreateProjectCommand->execute() at phar:///private/var/www/d.tomasi/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
 Symfony\Component\Console\Command\Command->run() at phar:///private/var/www/d.tomasi/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at phar:///private/var/www/d.tomasi/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/Console/Application.php:147
 Composer\Console\Application->doRun() at phar:///private/var/www/d.tomasi/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at phar:///private/var/www/d.tomasi/composer.phar/src/Composer/Console/Application.php:84
 Composer\Console\Application->run() at phar:///private/var/www/d.tomasi/composer.phar/bin/composer:43
 require() at /private/var/www/d.tomasi/composer.phar:25
leofeyer commented 9 years ago

I found the problem: the console commands are initializing the Contao 3 framework and the Contao 3 framework triggers the Automator::generateSymlinks() method. I will remove this call from the listener.

@contao/developers Do we really want to initialize the Contao 3 framework on the console?

leofeyer commented 9 years ago

Changed in b0f82c6fb3210c40e47135b4d83d01ffad777dcb. @dtomasi Please wait a few minutes until packagist has updated its cache and then try again. Thanks for your help.

dtomasi commented 9 years ago

+1 This works perfectly! Thank you!

aschempp commented 9 years ago

I thought we do need the framework for our Automator tasks?

leofeyer commented 9 years ago

@aschempp Actually we should be able to decide on a per command basis. Similar to extending ContainerAware there should be a FrameworkDependendCommand or something alike.

discordier commented 9 years ago

I agree, we should limit the initialization to commands that need the framework.

But please not by extending a command class but by implementing an interface.

leofeyer commented 9 years ago

But how is the event listener supposed to know about it?

dtomasi commented 9 years ago

Maybe this could be done by ConsoleEvents::COMMAND. with something like this:

use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\ConsoleEvents;

    public function isFrameworkDependendCommand(ConsoleCommandEvent $event) {

        $ref = new ReflectionClass($event->getCommand());
        if ($ref->implementsInterface('FrameworkDependentCommand')) {
            // Initialize Framework and maybe inject it
        }
    }

PS.: @leofeyer nice pic ;-)

dtomasi commented 9 years ago

see: https://github.com/ContaoBlackforest/core-bundle/commit/5456510d8e94b88f1c4605b7d3c47f64a97d6d1f

leofeyer commented 9 years ago

As discussed on Mumble on March, 26th:

dtomasi commented 9 years ago

The interface should be called Contao\Command\ContaoFrameworkDependentInterface.

Isn´t it Contao\CoreBundle\Command\ContaoFrameworkDependentInterface?

Toflar commented 9 years ago

Isn´t it Contao\CoreBundle\Command\ContaoFrameworkDependentInterface?

Of course :)

dtomasi commented 9 years ago

Whats about the $this->booted? Should we create a static privat $isBooted?

Toflar commented 9 years ago

Whats about the $this->booted? Should we create a static privat $isBooted?

Yeah but @leofeyer will do :P

dtomasi commented 9 years ago

Ok, should I do a PR of the current state??

leofeyer commented 9 years ago

Closed in favor of the PR (contao/core-bundle#159). @dtomasi Thanks a lot for your help :)