I have inherited a rather complicated Symfony 3 project (I'm using Laravel mostly nowadays - it's been years since I used Symfony) so this is a bit out of my wheelhouse.
I did a composer update and it built ok.
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating twig/twig 1.x-dev (e8555dc => 1445246): Checking out 1445246d8e
Writing lock file
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
// Clearing the cache for the dev environment with debug
// true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
Trying to install assets as relative symbolic links.
-- -------- ----------------
Bundle Method / Error
-- -------- ----------------
[OK] All assets were successfully installed.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
I cleared the cache
php bin/console cache:clear --no-warmup --env local
When I browse to my local development URL, I get:
Whoops, looks like something went wrong.
(4/4) Twig_Error_Runtime
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").
in exception_full.html.twig (line 1)
at Twig_Template->displayWithErrorHandling(array('status_code' => 500, 'status_text' => 'Internal Server Error', 'exception' => object(FlattenException), 'logger' => object(Logger), 'currentContent' => '', 'app' => object(AppVariable)), array('head' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_head'), 'title' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_title'), 'body' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_body')))
in Template.php (line 403)
<snip/>
(3/4) ContextErrorException
Notice: Undefined offset: 0
in Profiler.php (line 23)
at Twig_Extension_Profiler->enter(object(Twig_Profiler_Profile))
in ProfilerExtension.php (line 40)
<snip/>
(2/4) Twig_Error_Runtime
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").
in base.html.twig (line 11)
at Twig_Template->displayBlock('javascripts', array('env' => 'local', 'app' => object(AppVariable)), array('title' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_title'), 'stylesheets' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_stylesheets'), 'body' => array(object(__TwigTemplate_888836406c51f4232014f646f747310c541800b61ef418c11fbfcee42a1afe9b), 'block_body'), 'javascripts' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_javascripts')))
in Environment.php(467) : eval()'d code (line 51)
<snip/>
(1/4) ContextErrorException
Notice: Undefined offset: 0
in Profiler.php (line 23)
at Twig_Extension_Profiler->enter(object(Twig_Profiler_Profile))
in ProfilerExtension.php (line 40)
Since this appears to be an issue with vendor files, I'm not sure where to go from here.
The last error in the logs is
[2018-03-02 15:56:53] request.CRITICAL: Exception thrown when handling an exception (Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0"). at /Projects/myproject/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig line 1) {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Notice: Undefined offset: 0\"). at /Projects/myproject/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig:1, Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: Undefined offset: 0 at /Projects/myproject/vendor/twig/twig/lib/Twig/Extension/Profiler.php:23)"} []
Try to add this line in composer.json
"twig/twig": "2.4.4"
For me worked.
It seems the last updates for twig 2.4.5 had this problem.
I found the answer here:
https://github.com/twigphp/Twig/issues/2627
Related
I upgrade from synfony 4 to 5. Then i try to test my registration page and get this: Could not load type "App\Form\RepeatedType": class does not exist.
What i have try:
composer install --no-dev --optimize-autoloader (i found this online)
The result:
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 0 installs, 0 updates, 5 removals
- Removing symfony/web-profiler-bundle (v5.4.8)
- Removing symfony/maker-bundle (v1.42.0)
- Removing nikic/php-parser (v4.13.2)
- Removing doctrine/doctrine-fixtures-bundle (3.4.2)
- Removing doctrine/data-fixtures (1.5.3)
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
69 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#83
!! #message: """
!! Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle".\n
!! Did you forget a "use" statement for another namespace?
!! """
!! #code: 0
!! #file: "D:\cours\symfony\blog\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php"
!! #line: 132
!! trace: {
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php:132 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:386 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:786 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:128 { …}
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Console\Application.php:168 { …}
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Console\Application.php:74 { …}
!! D:\cours\symfony\blog\vendor\symfony\console\Application.php:171 { …}
!! D:\cours\symfony\blog\vendor\symfony\runtime\Runner\Symfony\ConsoleApplicationRunner.php:54 { …}
!! D:\cours\symfony\blog\vendor\autoload_runtime.php:35 { …}
!! D:\cours\symfony\blog\bin\console:11 {
!! ›
!! › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "D:\cours\symfony\blog\vendor\autoload_runtime.php"
!! }
!! }
!! }
!! }
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! 2022-05-17T00:33:06+02:00 [critical] Uncaught Error: Class 'Symfony\Bundle\MakerBundle\MakerBundle' not found
!!
Script #auto-scripts was called via post-install-cmd
WEIRD because others forms worked just before (and now they are broken saying: Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle". Did you forget a "use" statement for another namespace?)
composer require symfony/maker-bundle --dev
Now it's working again except for the registration page ("App\Form\RepeatedType": class does not exist.).
It's worth notting that my autocomplet find Symfony\Component\Form\Extension\Core\Type\RepeatedType in the folder.
And sometimes when i clear cache, it crash when optimizing.
Thanks for reading.
In symfony 5 the use statement for RepeatedType is use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
And to use for let's say a password fiel you would type something like:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class,
'required' => false,
'mapped' => false,
'first_options' => ['label' => 'New password'],
'second_options' => ['label' => 'Repeat password'],
]);
I try to deploy my Symfony application and when I use composer to install dependencies, I get an error.
I saw that there were people who had the same problem but I didn' t find a solution. Like change in .env APP_ENV=dev to APP_ENV=prod.
Here the logs :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!! Did you forget a "use" statement for another namespace? in /tmp/build.YZSXu7Ir2b/src/Kernel.php:23
I use DoctrineFixturesBundle only in dev environment :
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.1",
"fzaninotto/faker": "^1.8",
"symfony/profiler-pack": "^1.0"
}
Here my config/bundles.php :
...
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
...
And here Line 23 of Kernel.php :
...
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class(); // line 23
}
}
}
...
if I understand your problem, you just have Composer Install, but the best is to do that composer install --no-dev --optimize-autoloader it's explained Here. Otherwise, I do not know
Please check if directory "vendor/doctrine/doctrine-fixtures-bundle" exists and if there are files inside - specifically the "vendor/doctrine/doctrine-fixtures-bundle/DoctrineFixturesBundle.php"
If they are not there then it seems you didnt executed "composer update" to add the package. In such case please try:
COMPOSER_MEMORY_LIMIT=-1 composer update doctrine/doctrine-fixtures-bundle
You should see something like:
- Installing doctrine/data-fixtures (v1.3.1): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.2.2): Loading from cache
I'm trying to install Ckeditor on my symfony 4 project (4.1.4);
When I try to :
bin/console ckeditor:install
I have this error :
Unable to download CKEditor ZIP archive from "https://github.com/ckeditor/ckeditor-releases/archive/full/latest.zip". (file_get_contents(https://github.com/ckeditor/ckeditor-releases/archive/f
ull/latest.zip): failed to open stream: operation failed)
After searching on google, i dont find any solution to solve my problem.
composer -V :1.6.2
I checked my ssl config, php -r 'print_r(openssl_get_cert_locations());'
Array
(
[default_cert_file] => /usr/local/etc/openssl/cert.pem
[default_cert_file_env] => SSL_CERT_FILE
[default_cert_dir] => /usr/local/etc/openssl/certs
[default_cert_dir_env] => SSL_CERT_DIR
[default_private_dir] => /usr/local/etc/openssl/private
[default_default_cert_area] => /usr/local/etc/openssl
[ini_cafile] => /usr/local/etc/openssl/cert.pem
[ini_capath] =>
)
And to finish : ~/Sites/lblblb/feature/translator ●✚ bin/console ckeditor:install -vvv
Exception trace:
FOS\CKEditorBundle\Installer\CKEditorInstaller->createException() at /Users/yahiko/Sites/blblb/vendor/friendsofsymfony/ckeditor-bundle/src/Installer/CKEditorInstaller.php:183
FOS\CKEditorBundle\Installer\CKEditorInstaller->download() at /Users/yahiko/Sites/blblbl/vendor/friendsofsymfony/ckeditor-bundle/src/Installer/CKEditorInstaller.php:113
FOS\CKEditorBundle\Installer\CKEditorInstaller->install() at /Users/yahiko/Sites/blbll/vendor/friendsofsymfony/ckeditor-bundle/src/Command/CKEditorInstallerCommand.php:112
FOS\CKEditorBundle\Command\CKEditorInstallerCommand->execute() at /Users/yahiko/Sites/blblbl/vendor/symfony/console/Command/Command.php:251
Symfony\Component\Console\Command\Command->run() at /Users/yahiko/Sites/blblbl/vendor/symfony/console/Application.php:904
Symfony\Component\Console\Application->doRunCommand() at /Users/yahiko/Sites/blbbllb/vendor/symfony/framework-bundle/Console/Application.php:89
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /Users/yahiko/Sites/blblbl/vendor/symfony/console/Application.php:262
Symfony\Component\Console\Application->doRun() at /Users/yahiko/Sites/bblbllb/vendor/symfony/framework-bundle/Console/Application.php:75
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/yahiko/Sites/blblbl/vendor/symfony/console/Application.php:145
Symfony\Component\Console\Application->run() at /Users/yahiko/Sites/bblblbl/bin/console:39
Thank's :)
I try to release my web application using Symfony 4.0.6 on Elastic Beanstalk of Amazon Web Service. However, I have a problem about "Script cache:clear returned with error code 255 !! (Executor::NonZeroExitStatus)" when the application is deploying
I have updated the symfony/flex (v1.0.70 => v1.0.71) and I have checked it following.
$ composer install --no-dev --optimize-autoloader
~~~~
- Removing symfony/process (v4.0.6)
Generating optimized autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".
!! Did you forget a "use" statement for another namespace? in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php:32
!! Stack trace:
!! #0 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(403): App\Kernel->registerBundles()
!! #1 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(122): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!! #2 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\framework-bundle\Console\Application.php(64): Symfony\Component\HttpKernel\Kernel->boot()
!! #3 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\console\Application.php(143): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!! #4 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\bin\console(39) in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php on line 32
I think that we need to check three bundles following
class Kernel extends BaseKernel
{
public function registerBundles()
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
**yield new $class();**
}
}
}
cat /config/bundles.php
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Could you please give me an advice?
I think the problem is you don't pass the APP_ENV environment variable, so the script cache:clear is running in dev mode.
You should run APP_ENV=prod composer install --no-dev --optimize-autoloader
This is also mention on https://symfony.com/doc/current/deployment.html#c-install-update-your-vendors
Another option is to run composer install --no-dev --optimize-autoloader --no-scripts, with the extra flag no scripts will be executed, but I don't know if your application relies on scripts to be run.
Still does not work
In/etc/puppet/manifests/site.pp
file { "/home/render/installation/":
ensure => "directory",
owner => "render",
group => "render",
recurse => "true",
mode => "0750",
source => "puppet:///files/installation/",
}
Dir still is empty on client
ls /etc/puppet/files/installation/
1 2 3 4 5
On puppet client in log
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Failed to generate additional resources using 'eval_generate: Error 400 on SERVER: Not authorized to call search on /file_metadata/files/installation with {:checksum_type=>"md5", :recurse=>true, :links=>"manage"}
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Could not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation Could not retrieve file metadata for puppet:///files/installation: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation
Mar 21 12:28:12 lw-003 puppet-agent[28098]: Finished catalog run in 0.28 seconds
I had the same issue and found this question on Google. I had to change the path to the files for the manifests (modulename/manifests/init.pp):
"puppet:///files/installation/",
to:
"puppet:///modules/files/installation/",
The notation without /modules/ was deprecated in 2.7 and no longer supported in newer versions:
DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module 'modulename' when no 0.24.x clients are present
try this example,
file {
"/scratch/usern/testmod" :
ensure => directory,
source => "puppet:///files/testmod",
recurse => true,
owner => "usern",
group => "groupn",
mode => "0775",
backup => false,
}
You have to specify 'files' and if you are doing a recursive copy, specify 'recurse => true'. That might be the solution to your problem.
the 'fileserver.conf' should look something like the following :
]# cat /etc/puppet/fileserver.conf
[files]
path /etc/puppet/files
allow *