2012-03-03 2 views
2

내 appKernel.php은 다음과 같습니다symfony2가 내 번들을 복사하지 않는 이유는 무엇입니까?

: 나는 다음과 같은 얻을

php app/console assets:install web 

:

<?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'); 

내가 할 경우 : 같은

<?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'); 
    } 
} 

내 autoload.php 보인다

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 

내 BloggerBlogBundle이 복사되지 않습니까?

+0

여기에 '틱된'답변을 변경해야합니다.) 하하 – Jimbo

답변

16

참고 : OP의 답변이 짧고 너무 자세히 설명하지 않기 때문에 다음 독자를위한 심층적 인 답변을 제공하므로 잘하면 내가했던 것처럼 많이 파고 들지 않아도됩니다. ! :)

우리가 동일한 자습서를 다음과 동일한 문제가있는 것 같다, 위의 대답은 매우 설명하지 않고 나 자신을 파고 조금해야했다대로, 여기 정확히있어 뭐가 문제 야.

1 단계

귀하의 src/Blogger/BlogBundle 필요는 /resources 폴더에하는 public/css 폴더가 있습니다. 그래서 당신은 다음과 같이 CSS 파일을 배치해야합니다 : 존재하지 않는 경우

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

이 (나를 위해 존재하지 않았다)을 /public/css 폴더를 만듭니다.

당신은 당신을 위해 자동으로 /web에서 만든 심볼릭 링크 때문에이 액세스 할 수있는 할 수있는 assetic 관리 도구를 실행해야 2 단계.

php app/console assets:install web

이제 당신은 (리눅스에서 윈도우 탐색기/노틸러스 사용) dev 디렉토리를 열고 경우 /web/bundles/bloggerblog/css/<stylesheet>.css이 당신을 위해 자동으로 만들어 졌는지는 /web 폴더를 찾을 것을 알 수 있습니다!

이제 사용하여 코드에서 CSS 파일에 액세스 할 수 있습니다 :

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

참고 : '.CSS는'이 튜토리얼

에 대한 화면 'screen.css'로 대체된다. .. 그리고 그것은 그것 일 것임에 틀림 없다!

1

'php app/console assets : install web'을 실행 한 후에 자산이 번들의 Resources 폴더에서 웹/번들로 복사되지 않는 원래의 질문과 정확히 같은 문제가 있습니다. 'php app/console cache : clear --env = prod'명령을 사용하여 수정했습니다. 당신은 당신이 prod 자산을 다루거나 웹 디렉토리에서 환경을 자극하기 위해 자산을 설치한다는 것을 알 수 있듯이, 캐시를위한 명확한 캐시가 합리적입니다.분명 --env = 자극 2) $의 PHP 응용 프로그램/콘솔 자산 :

1) $의 PHP 응용 프로그램/콘솔 캐시 : 그래서 이렇게 웹 또는 $ PHP 응용 프로그램/콘솔 자산을 설치 : 설치 웹은 을 --symlink 3) $ php app/console assetic : dump --env = prod (Assetic으로 빌드하면,/web/bundle과는 반대로 CSS를/web/css에 덤프/결합합니다)

그 후에 모든 것이 바뀝니다. 당신은/web/bundles에있는 모든 자산과 assetic 덤프를/web/css에서 얻습니다. 그리고 이것들은 모두 prod env를위한 것입니다.

0

는 그냥 BlahBundle.php가

0

내가 Symfony3.3.13 오늘이 문제를 했어 문제가 public 디렉토리가 실제로 대문자이었다 리소스 디렉토리와 동일한 디렉토리에 있는지 확인이 문제를 가지고 있었다 Public, 설치 스크립트가 손상된 것 같습니다. 이름을 변경하면 즉시 작동합니다.

관련 문제