0

Переносил проект Symfony на хостинг. То что было в web закинул в public_html. Остальное просто в корень кинул. Вот получается prod окружение http://task1.esy.es/ и выдает ошибку 500. Настроил dev, чтобы посмотреть, что происходит. Что-то отображается http://task1.esy.es/app_dev.php, но не подгружает css и js - тоже на них ошибку 500 выдает. Может из-за того, что папка не web, а public_html называется. Я ради эксперимента в локальном проекте изменил web на public_html и он тоже не смог подгрузить, только 404 ошибку выдал, а не 500. Так вот может потому, что на хостинге папка public_html называется, а не web, вот он их и не подгружает. Как-то может в конфигах что-то подправить можно чтобы заработало? Или может дело в другом - логи может быть что скажут.

Вот логи в dev

[2016-08-07 00:50:49] request.INFO: Matched route "{route}". {"route":"record_index","route_parameters":{"_controller":"AppBundle\\Controller\\RecordController::indexAction","_route":"record_index"},"request_uri":"http://task1.esy.es/app_dev.php/","method":"GET"} []
[2016-08-07 00:50:49] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2, t0.surname AS surname_3, t0.patronymic AS patronymic_4, t0.d_ob AS d_ob_5, t0.phone AS phone_6, t0.id_town AS id_town_7, t0.id_street AS id_street_8 FROM records t0 [] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2 FROM town t0 WHERE t0.id = ? [5] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2, t0.id_town AS id_town_3 FROM street t0 WHERE t0.id = ? [9] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2 FROM town t0 WHERE t0.id = ? [3] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2, t0.id_town AS id_town_3 FROM street t0 WHERE t0.id = ? [6] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2 FROM town t0 WHERE t0.id = ? [1] []
[2016-08-07 00:50:49] doctrine.DEBUG: SELECT t0.id AS id_1, t0.name AS name_2, t0.id_town AS id_town_3 FROM street t0 WHERE t0.id = ? [3] []
[2016-08-07 00:51:00] request.INFO: Matched route "{route}". {"route":"_wdt","route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"49a528","_route":"_wdt"},"request_uri":"http://task1.esy.es/app_dev.php/_wdt/49a528","method":"GET"} []

Логи в prod

[2016-08-07 01:43:24] request.CRITICAL: Uncaught PHP Exception  Symfony\Component\Config\Exception\FileLoaderLoadException: "Bundle "WebProfilerBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in @WebProfilerBundle/Resources/config/routing/wdt.xml (which is being imported from "/home/u710835356/app/config/routing.yml"). Make sure the "WebProfilerBundle" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "@WebProfilerBundle/Resources/config/routing/wdt.xml" is not empty." at /home/u710835356/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php line 118 {"exception":"[object] (Symfony\\Component\\Config\\Exception\\FileLoaderLoadException(code: 0): Bundle \"WebProfilerBundle\" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in @WebProfilerBundle/Resources/config/routing/wdt.xml (which is being imported from \"/home/u710835356/app/config/routing.yml\"). Make sure the \"WebProfilerBundle\" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path \"@WebProfilerBundle/Resources/config/routing/wdt.xml\" is not empty. at /home/u710835356/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:118, InvalidArgumentException(code: 0): Bundle \"WebProfilerBundle\" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? at /home/u710835356/var/bootstrap.php.cache:2348)"} []

Логи в prod помогли понять в чем дело в AppKernel.php подключался new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); только для dev и test окружения, подключил его выше для любого окружения и теперь есть доступ к http://task1.esy.es/ правда css и js пока не подгружает. 404 выдает. И вот такие логи

[2016-08-07 06:13:32] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/app/js/jquery.min.js" (from "http://task1.esy.es/new")" at /home/u710835356/var/cache/prod/classes.php line 2774 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/app/js/jquery.min.js\" (from \"http://task1.esy.es/new\") at /home/u710835356/var/cache/prod/classes.php:2774, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/u710835356/var/cache/prod/appProdUrlMatcher.php:302)"} []
[2016-08-07 06:13:33] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /bundles/app/css/tablestyle.css" (from "http://task1.esy.es/new")" at /home/u710835356/var/cache/prod/classes.php line 2774 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /bundles/app/css/tablestyle.css\" (from \"http://task1.esy.es/new\") at /home/u710835356/var/cache/prod/classes.php:2774, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/u710835356/var/cache/prod/appProdUrlMatcher.php:302)"} []
3
  • 1
    "только 404 ошибку выдал, а не 500" Во первых всегда проверяют версию PHP на сервере , посмотрите какие корректные настройки нужны для правильной работы symfony.com/doc/2.8/reference/requirements.html А потом двигайтесь дальше 7 авг 2016 в 9:16
  • Исправил кое-что в папке public_html, с папкой bundles были проблемы. Теперь ошибка 302 7 авг 2016 в 12:45
  • Заметил, что если подгружаю через asset('bundles/app/js/jquery.min.js') то не работает, если через asset('jquery.min.js') , то на dev работает, а на prod хоть и выдает 304 - но тоже работает. Получается можно и так подгрузить, но хотелось б по нормальному 7 авг 2016 в 13:10

1 ответ 1

2

Для того, чтобы использовать ресурсы пакетов в web окружении, нужно сгенирировать в директорию web ссылки на них. Это делается командой

php путь/до/console assets:install web --symlink

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.