Strong Like Bull
Strong Like Bull

Reputation: 11297

Why is symfony2 not copying my bundle over?

My appKernel.php looks like this:

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
            new Blogger\BlogBundle\BloggerBlogBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}

My autoload.php looks like:

<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
    'Sensio'           => __DIR__.'/../vendor/bundles',
    'JMS'              => __DIR__.'/../vendor/bundles',
    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
    'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
    'Monolog'          => __DIR__.'/../vendor/monolog/src',
    'Assetic'          => __DIR__.'/../vendor/assetic/src',
    'Metadata'         => __DIR__.'/../vendor/metadata/src',
));
$loader->registerPrefixes(array(
    'Twig_Extensions_' => __DIR__.'/../vendor/twig-extensions/lib',
    'Twig_'            => __DIR__.'/../vendor/twig/lib',
));

// intl
if (!function_exists('intl_get_error_code')) {
    require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';

    $loader->registerPrefixFallbacks(array(__DIR__.'/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs'));
}

$loader->registerNamespaceFallbacks(array(
    __DIR__.'/../src',
));
$loader->register();

AnnotationRegistry::registerLoader(function($class) use ($loader) {
    $loader->loadClass($class);
    return class_exists($class, false);
});
AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');

// Swiftmailer needs a special autoloader to allow
// the lazy loading of the init file (which is expensive)
require_once __DIR__.'/../vendor/swiftmailer/lib/classes/Swift.php';
Swift::registerAutoload(__DIR__.'/../vendor/swiftmailer/lib/swift_init.php');

When I do:

php app/console assets:install web

I get the following:

Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Acme\DemoBundle into web/bundles/acmedemo
Installing assets for Symfony\Bundle\WebProfilerBundle into web/bundles/webprofiler
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution

Why is my BloggerBlogBundle not getting copied over?

Upvotes: 3

Views: 8485

Answers (4)

Martin Lyne
Martin Lyne

Reputation: 3065

I've had this issue today with Symfony3.3.13 and the problem was the public directory was actually capitalised Public, which seems to break the install script. Changing the name and it worked immediately.

Upvotes: 0

jim smith
jim smith

Reputation: 2454

Just had this problem, ensure that the BlahBundle.php is located in the same directory as the Resources directory

Upvotes: 0

Dung
Dung

Reputation: 20565

I have the the exact same problem with the original question, where assets are not copied over from Resources folder of bundles to web/bundles after running 'php app/console assets:install web' so what i did was running this command 'php app/console cache:clear --env=prod' and that fixed it. As you can see that you are dealing with prod assets or installing assets to prod environment in web directory, so clear cach for prod is reasonable. So do this:

1) $ php app/console cache:clear --env=prod 2) $ php app/console assets:install web OR $ php app/console assets:install web --symlink 3) $ php app/console assetic:dump --env=prod (If you use built in Assetic, it will dump/combine css to one big one in /web/css as opposed to /web/bundles)

everything goes in place after that. you get all assets in your /web/bundles and assetic dump in /web/css and all of these are for prod env.

Upvotes: 1

Jimbo
Jimbo

Reputation: 26523

Note: As OP's answer is short and doesn't really go into too much detail, here's a more in-depth answer for future readers, so hopefully you don't have to do as much digging as I did! :)

It seems that we're following the exact same tutorial and have the exact same issue, and as the answer above isn't very descriptive and I had to do a little digging myself, here's exactly what's wrong.

Step 1

Your src/Blogger/BlogBundle needs to have, in the /resources folder, a public/css folder. So you need to place your CSS files as follows:

src/Blogger/BlogBundle/resources/public/css/<stylesheet>.css

Create the /public/css folder if it doesn't exist (it didn't exist for me).

Step 2 You need to run the assetic management tool to have a symlink created in /web automatically for you so these can be accessed.

php app/console assets:install web

You now will notice that if you open (using windows explorer / nautilus on linux) your dev directory and find the /web folder, that /web/bundles/bloggerblog/css/<stylesheet>.css has been created automatically for you!

You can now access your CSS files in your code using:

<link href="{{ asset('/bundles/bloggerblog/css/<stylesheet>.css') }}" type="text/css" rel="stylesheet" />

Note: '.css' is replaced with screen 'screen.css' for this tutorial

...and that should be it!

Upvotes: 17

Related Questions