Symfony2资产问题

时间:2015-01-21 14:43:23

标签: symfony assetic

我最近开始在使用Symfony2的网站上添加新功能。 在创建了一个与其他已经工作的非常相似的新捆绑包之后,我创建了一个按钮来访问该功能。

但是我在浏览器的开发者工具中遇到了以下错误:

GET prod.project.local/bundles/calinobase/css//calino-main-colors.css            prod.project.local/:35
GET prod.project.local/bundles/calinobase/css//main-colors.css                   prod.project.local/:28
GET prod.project.local/bundles/calinobase/css//bootstrap-override-colors.css     prod.project.local/:27
GET prod.project.local/bundles/calinobase/css//buttons-colors.css                prod.project.local/:29
GET prod.project.local/bundles/calinobase/css//menus-colors.css                  prod.project.local/:33
GET prod.project.local/bundles/calinobase/css//forms-colors.css                  prod.project.local/:32
GET prod.project.local/bundles/calinobase/css//content-colors.css                prod.project.local/:30
GET prod.project.local/bundles/calinobase/css//mag-colors.css                    prod.project.local/:31
GET prod.project.local/bundles/calinobase/css//search-colors.css                 prod.project.local/:34

在我的页面上加上错误500.

经过一些研究后,我发现它来自stylesheets.html.twig文件:

<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/bootstrap-override-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/main-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/buttons-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/content-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/mag-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/forms-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/menus-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/search-colors.css') }}" type="text/css" media="screen" />
<link rel="stylesheet" href="{{ asset('bundles/calinobase/css/' ~ colorTheme ~ '/calino-main-colors.css') }}" type="text/css" media="screen" />

显然它找不到colorTheme,它在使用样式表时在layout.html.twig中设置:

{% block stylesheets %}
            {{ include('::stylesheets.html.twig', {colorTheme: app.user.color|default('bfc100')}, with_context = false) }}
{% endblock %}

在我的日志中,我遇到以下错误:

[2015-01-21 15:22:42] request.INFO: Matched route "calinobase_homepage" (parameters: "_controller": "Calino\BaseBundle\Controller\DefaultController::indexAction", "_route": "calinobase_homepage") [] []
[2015-01-21 15:22:43] security.INFO: Populated SecurityContext with an anonymous Token [] []
[2015-01-21 15:22:43] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException: "An exception occurred while executing 'SELECT a0_.id AS id0, a0_.creaDate AS creaDate1, a0_.editDate AS editDate2, a0_.title AS title3, a0_.slug AS slug4, a0_.intro AS intro5, a0_.content AS content6, a0_.alaune AS alaune7, a0_.published AS published8, a0_.thread_id AS thread_id9, a0_.articleTheme_id AS articleTheme_id10, a0_.avatar_id AS avatar_id11 FROM article_mag a0_ WHERE a0_.alaune = 1 ORDER BY a0_.creaDate DESC LIMIT 1':  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'calinofriendsdb.article_mag' doesn't exist" at /var/www/prod.project.local/htdocs/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 53 {"exception":"[object] (Doctrine\\DBAL\\Exception\\TableNotFoundException(code: 0): An exception occurred while executing 'SELECT a0_.id AS id0, a0_.creaDate AS creaDate1, a0_.editDate AS editDate2, a0_.title AS title3, a0_.slug AS slug4, a0_.intro AS intro5, a0_.content AS content6, a0_.alaune AS alaune7, a0_.published AS published8, a0_.thread_id AS thread_id9, a0_.articleTheme_id AS articleTheme_id10, a0_.avatar_id AS avatar_id11 FROM article_mag a0_ WHERE a0_.alaune = 1 ORDER BY a0_.creaDate DESC LIMIT 1':\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'calinofriendsdb.article_mag' doesn't exist at /var/www/prod.project.local/htdocs/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:53, Doctrine\\DBAL\\Driver\\PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'calinofriendsdb.article_mag' doesn't exist at /var/www/prod.project.local/htdocs/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:106, PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'calinofriendsdb.article_mag' doesn't exist at /var/www/prod.project.local/htdocs/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104)"} []
[2015-01-21 15:22:43] security.DEBUG: Write SecurityContext in the session [] []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//forms-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//forms-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//main-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//main-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//bootstrap-override-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//bootstrap-override-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//content-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//content-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//buttons-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//buttons-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//mag-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//mag-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:44] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//search-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//search-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:44] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//calino-main-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//calino-main-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []
[2015-01-21 15:22:44] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/calinobase/css//menus-colors.css" (from "http://prod.project.local/")" at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php line 3098 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/calinobase/css//menus-colors.css\" (from \"http://prod.project.local/\") at /var/www/prod.project.local/htdocs/current/app/cache/prod/classes.php:3098, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /var/www/prod.project.local/htdocs/current/app/cache/prod/appProdUrlMatcher.php:1498)"} []

我使用PhpStorm开发,所以当我鼠标移除&#34; calinobase&#34;在我的stylesheets.html.twig中,它显示&#34;缺少资产&#34;所以我尝试使用 php app / console资产:安装--verbose 但我得到了:

Installing assets as hard copies.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
 
 
                                                                              
  [Symfony\Component\Filesystem\Exception\IOException]                      
  Failed to remove file "web/bundles/framework/images/blue_picto_more.gif". 
                                                                              
 
 
Exception trace:
 () at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:173
 Symfony\Component\Filesystem\Filesystem->remove() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:160
 Symfony\Component\Filesystem\Filesystem->remove() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php:160
 Symfony\Component\Filesystem\Filesystem->remove() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php:98
 Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand->execute() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:253
 Symfony\Component\Console\Command\Command->run() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
 Symfony\Component\Console\Application->doRunCommand() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/kemps/dev2/calinofriends/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at /home/kemps/dev2/calinofriends/app/console:22
 
 
assets:install [--symlink] [--relative] [target]

不知道如何处理错误,我很乐意提供任何帮助。提前感谢任何能帮助我的人。

编辑:我的Symfony项目位于安装了Vagrant的虚拟机上,配置了Puppetmaster并且具有NFS共享文件夹

1 个答案:

答案 0 :(得分:0)

无法删除文件“web / bundles / framework / images / blue_picto_more.gif”。

您的权限有问题, 如果从网站上传了blue_picto_more.gif,则表示权限已设置为网络服务器帐户。 通常是“nginx或www-data”。

如果您只是在本地使用此站点或您的开发服务器,您只需将Web文件夹设置为777(不要在生产时执行此操作)。

在命令行中使用它:

chmod -R 777 /pathto/web

这个是生产友好的:  将权限更改为您从控制台登录的帐户

chown -R the_user web