Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

form:generate throws ErrorException #180

Open
g11c opened this Issue · 6 comments

3 participants

@g11c

i work with symfony-standard 2.1
my composer.json file:

{
    "name": "xxx",
    "description": "xxx",
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "minimum-stability": "dev",
    "authors": [
        {
            "name": "g11c",
            "email": "g11c@gmx.at"
        }
    ],
    "require": {
        "php": ">=5.3.2",
        "ext-iconv": "*",
        "ext-intl": "*",
        "igorw/composer-yaml": "dev-master",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.0.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "propel/propel-bundle": "1.1.*"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}

i followed the installation of propel on http://www.propelorm.org/cookbook/symfony2/working-with-symfony2.html
then i used the command:

php app/console propel:form:generate @AcmeDemoBundle Book Author

and it throws following exception:

  [ErrorException]
  Catchable Fatal Error: Argument 1 passed to Propel\PropelBundle\Command\AbstractCommand::getSchemasFromBundle() 
  must implement interface Symfony\Component\HttpKernel\Bundle\BundleInterface, null given, 
  called in \vendor\propel\propel-bundle\Propel\PropelBundle\Command\FormGenerateCommand.php on line 55 
  and defined in \vendor\propel\propel-bundle\Propel\PropelBundle\Command\AbstractCommand.php line 268

i have tried this a few times (creating new projects and following the installation instruction of propel); i also tried it by installing all tags (one after another) of branch 1.1, but i always get the ErrorException from above.
i have searched if someone has the same problem, but i haven´t found anybody and i don´t know anymore what i could do.

@willdurand
Owner

It could be an issue related to the Symfony2 version...

@c33s

+1
i also get this exception on running this command
running sf 2.1.3 installed via composer

composer.json

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.0.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "propel/propel-bundle": "1.1.*"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    }
}
@c33s

after going through the code and some var_dumps, i found the solution, it is a windows powershell problem, the @ sign is an operator there, see http://stackoverflow.com/questions/363884/what-does-the-symbol-do-in-powershell
so in the windows powershell the bundle name has to be quoted

php app/console propel:form:generate '@AcmeStoreBundle'

@willdurand
Owner

Can we close this issue then?

@c33s

adding a better error handling would be a good thing, something like:

https://github.com/propelorm/PropelBundle/blob/1.1/Command/AbstractCommand.php#L95

        if ($input->hasArgument('bundle')) {
            if ( '@' === substr($input->getArgument('bundle'), 0, 1)) {
                $this->bundle = $this
                    ->getContainer()
                    ->get('kernel')
                    ->getBundle(substr($input->getArgument('bundle'), 1));
             }

             if ($this->bundle == null)
             {
                 /*
                    something like abort the command and print a helpful message
                    - invalid bundlename
                    - have you prefixed it with @?
                    - do you use powershell? -> quote the command

                 */
             }

        }

should this be handled in this ticket or should we create a new one?

@willdurand
Owner

True, we should throw an exception with a useful message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.