I cannot disable Symfony3 cache for my project, can you please help me?
Things that I already tried to do:
commenting the line $kernel->loadClassCache(); in web/app_dev.php
adding
twig:
cache: false
to config_dev.yml
My $kernel instantiation in app_dev.php: $kernel = new AppKernel('dev', true);
Related
File:
app.php
Description:
I want replace the line 11 with:
$kernel = new AppKernel('dev', true);
Instead of:
$kernel = new AppKernel('prod', false);
main.yml file:
I'm trying to do this, but isn't work:
- name: Change to Symfony development enviroment for reflect the changes directly on the vagrant box
replace: dest=/vagrant/symfony-standard/web/app.php regexp='$kernel = new AppKernel('prod', false);' replace='$kernel = new AppKernel('dev', true);' backup=yes
Terminal:
TASK [symfony-standard : Change to Symfony development enviroment for reflect the changes directly on the vagrant box] ***
task path: /vagrant/playbooks/roles/symfony-standard/tasks/main.yml:49
ok: [default] => {"changed": false, "msg": ""}
I think you need to escape the $ sign, try to do something like this:
- name: Change to Symfony development enviroment for reflect the changes directly on the vagrant box
replace:
dest: /vagrant/symfony-standard/web/app.php
regexp: \$kernel = new.*$
replace: $kernel = new AppKernel('dev', true);
Please also try this one:
\$kernel = new AppKernel\('prod', false\);
The problem is I see trace error pages in production mode, in Symfony app.
I have this in app.php:
$kernel = new AppKernel('prod', true);
And I have done:
php app/console cache:clear --env=prod
Ok, I was completely wrong! The purpose of the second parameter in $kernel = new AppKernel('prod', true); is to enable/disable the debug mode. You can read the doc here: https://symfony.com/doc/current/configuration/environments.html
The issue was solved by setting to false the debug mode.
I have the following new environment:
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
// Use APC for autoloading to improve performance
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application
/*
$loader = new ApcClassLoader('sf2', $loader);
$loader->register(true);
*/
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('mobile', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
however when I do the following:
sudo php app/console assetic:dump --env=mobile
it gives me:
Clearing the cache for the mobile environment with debug true
How is it possible that debug is set to true while I have specifically in the new AppKernel('mobile' false);
I have cleared the cache and everything but it is still the same
When I do the following:
$kernel = $this->get('kernel');
ladybug_dump($kernel->isDebug());
this returns false, however it's just the console command that is not getting it right
sudo php app/console assetic:dump --env=dev --no-debug
after working with my project on dev mod, i found some problems with prod on OVH.
it shows me a blank page ! i try to follow the issue on app.php and i found that the problem persist with the execution of $response = $kernel->handle($request); and it don't logging on prod.
so when i change the row on app.php : $kernel = new AppKernel('prod', false); with $kernel = new AppKernel('dev', false); it works well !!!
here's my app.php
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <thomas.rabaix#sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
umask(0000);
require_once __DIR__ . '/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/AppKernel.php';
//use Symfony\Component\HttpFoundation\Request;
// if you want to use the SonataPageBundle with multisite
// using different relative paths, you must change the request
// object to use the SiteRequest
use Sonata\PageBundle\Request\SiteRequest as Request;
$request = Request::createFromGlobals();
$kernel = new AppKernel('prod', false);
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
EDIT :
in dev and prod local mode test it works well with
php app/console cache:clear --env=prod --no-debug
php app/console assets:install web_directory
php app/console assetic:dump web_directory
should i add or install php5 on my project ?
EDIT :
my project contains : sonata-project, fosUserBundle,etc...
EDIT
the problem was on config_prod.xml
doctrine:
orm:
entity_managers:
default:
metadata_cache_driver: apc
query_cache_driver: apc
result_cache_driver: apc
intil now after it return an error 500 ! why ? because of apc was not enabled !
so my question how to enable apc on OVH pro !
Go to web/config.php and comment ot the following lines:
if (!in_array(#$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('This script is only accessible from localhost.');
}
That will enable the config.php to be called from "extern". Don't forget to remove the comments after you've checked everything.
If you have console access on the production server, enter the root directory of your project and call php app/check.php to run the checks on the console.
I have this problem for days now... I just do a fresh install on syfmony but after i create a bundle from symfony console i get this error from the webpage...
ContextErrorException: Warning: is_dir(): open_basedir restriction in effect.
File(/srv/www/backend.tacon.eu/web) is not within the allowed path(s): (/var/www/clients/client1/web5/web:/var/www/clients/client1/web5/private:/var/www/clients/client1/web5/tmp:/var/www/backend.tacon.eu/web:/srv/www/backend.tacon.eu/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web5/web/back/vendor/symfony/symfony/src/Symfony/Component/Process/ExecutableFinder.php line 59
I don't know why is this happening. This is not my first symfony project and this never happens. Also on the same server i have various symfony projects.
Thanks in advance
I had the same problem after refresh install symfony using composer.
I have solved this issue by editing php configuration file (php.ini).
Set the open_basedir option to null.
More about open_basedir
From ISPConfig:
WebSites-> Your Site -> Options -> PHP open_basedir ->
Add :/srv/www/backend.tacon.eu/web at the end of line
if you face this error on live server then you can solve this problem like this-
<?php
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('prod', true);
$kernel->loadClassCache();
// wrap the default AppKernel with the AppCache one
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
in line $kernel = new AppKernel('prod', true); you may change it "prod" or "dev" and it's value like true or false;