为什么symfony2没有复制我的包?

jin*_*ini 3 php symfony

我的appKernel.php看起来像这样:

<?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');
    }
}
Run Code Online (Sandbox Code Playgroud)

我的autoload.php看起来像:

<?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');
Run Code Online (Sandbox Code Playgroud)

当我做:

php app/console assets:install web
Run Code Online (Sandbox Code Playgroud)

我得到以下内容:

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
Run Code Online (Sandbox Code Playgroud)

为什么我的BloggerBlogBu​​ndle没有被复制过来?

Jim*_*mbo 17

注意:由于OP的答案很短,并没有真正详细说明,这里对未来的读者来说是一个更深入的答案,所以希望你不必像我那样做那么多的挖掘!:)

看来,我们一直遵循完全相同的教程,并有相同的问题,并在上述答案是不是很描述,我不得不做一些挖掘自己,这里有究竟出了什么问题.

步骤1

src/Blogger/BlogBundle需要在/resources文件夹中拥有一个public/css文件夹.所以你需要放置你的CSS文件,如下所示:

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

/public/css如果该文件夹不存在,则创建该文件夹(它对我来说不存在).

步骤2 您需要运行资产管理工具以/web自动为您创建符号链接,以便可以访问这些符号链接.

php app/console assets:install web

您现在会注意到,如果您打开(使用Linux上的Windows资源管理器/ nautilus)您的开发目录并找到已自动为您创建的/web文件夹/web/bundles/bloggerblog/css/<stylesheet>.css!

您现在可以使用以下代码访问代码中的CSS文件:

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

注意:本教程的'.css'替换为屏幕'screen.css'

......那应该是它!