Symfony "app_dev.php" 缓存未清除
Symfony "app_dev.php" cache not clearing
我正在使用 symfony 并按照有关使用 app_dev.php
工作的文档进行操作而不必担心缓存...但它对我不起作用。我经常被迫 clear_cache 查看我在 twig 模板中的更改!
我的 app_dev.php
:
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
//$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
如有任何帮助,我们将不胜感激。
[编辑]
config.yml :
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
framework:
#esi: ~
translator: { fallbacks: [%locale%] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
prod_server_url: "%prod_server_url%"
ovh_applicationSecret: "%ovh_applicationSecret%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
dql:
datetime_functions:
date: DoctrineExtensions\Query\Mysql\Date
date_format: DoctrineExtensions\Query\Mysql\DateFormat
dateadd: DoctrineExtensions\Query\Mysql\DateAdd
datesub: DoctrineExtensions\Query\Mysql\DateSub
datediff: DoctrineExtensions\Query\Mysql\DateDiff
day: DoctrineExtensions\Query\Mysql\Day
dayname: DoctrineExtensions\Query\Mysql\DayName
dayofweek: DoctrineExtensions\Query\Mysql\DayOfWeek
dayofyear: DoctrineExtensions\Query\Mysql\DayOfYear
div: DoctrineExtensions\Query\Mysql\Div
from_unixtime: DoctrineExtensions\Query\Mysql\FromUnixtime
last_day: DoctrineExtensions\Query\Mysql\LastDay
minute: DoctrineExtensions\Query\Mysql\Minute
now: DoctrineExtensions\Query\Mysql\Now
month: DoctrineExtensions\Query\Mysql\Month
monthname: DoctrineExtensions\Query\Mysql\MonthName
second: DoctrineExtensions\Query\Mysql\Second
strtodate: DoctrineExtensions\Query\Mysql\StrToDate
time: DoctrineExtensions\Query\Mysql\Time
timediff: DoctrineExtensions\Query\Mysql\TimeDiff
timestampadd: DoctrineExtensions\Query\Mysql\TimestampAdd
timestampdiff: DoctrineExtensions\Query\Mysql\TimestampDiff
week: DoctrineExtensions\Query\Mysql\Week
weekday: DoctrineExtensions\Query\Mysql\WeekDay
year: DoctrineExtensions\Query\Mysql\Year
yearweek: DoctrineExtensions\Query\Mysql\YearWeek
unix_timestamp: DoctrineExtensions\Query\Mysql\UnixTimestamp
numeric_functions:
acos: DoctrineExtensions\Query\Mysql\Acos
asin: DoctrineExtensions\Query\Mysql\Asin
atan2: DoctrineExtensions\Query\Mysql\Atan2
atan: DoctrineExtensions\Query\Mysql\Atan
bit_count: DoctrineExtensions\Query\Mysql\BitCount
bit_xor: DoctrineExtensions\Query\Mysql\BitXor
ceil: DoctrineExtensions\Query\Mysql\Ceil
cos: DoctrineExtensions\Query\Mysql\Cos
cot: DoctrineExtensions\Query\Mysql\Cot
floor: DoctrineExtensions\Query\Mysql\Floor
hour: DoctrineExtensions\Query\Mysql\Hour
pi: DoctrineExtensions\Query\Mysql\Pi
power: DoctrineExtensions\Query\Mysql\Power
quarter: DoctrineExtensions\Query\Mysql\Quarter
rand: DoctrineExtensions\Query\Mysql\Rand
round: DoctrineExtensions\Query\Mysql\Round
stddev: DoctrineExtensions\Query\Mysql\StdDev
sin: DoctrineExtensions\Query\Mysql\Sin
std: DoctrineExtensions\Query\Mysql\Std
tan: DoctrineExtensions\Query\Mysql\Tan
string_functions:
ascii: DoctrineExtensions\Query\Mysql\Ascii
binary: DoctrineExtensions\Query\Mysql\Binary
char_length: DoctrineExtensions\Query\Mysql\CharLength
concat_ws: DoctrineExtensions\Query\Mysql\ConcatWs
countif: DoctrineExtensions\Query\Mysql\CountIf
crc32: DoctrineExtensions\Query\Mysql\Crc32
degrees: DoctrineExtensions\Query\Mysql\Degrees
field: DoctrineExtensions\Query\Mysql\Field
find_in_set: DoctrineExtensions\Query\Mysql\FindInSet
group_concat: DoctrineExtensions\Query\Mysql\GroupConcat
ifelse: DoctrineExtensions\Query\Mysql\IfElse
ifnull: DoctrineExtensions\Query\Mysql\IfNull
least: DoctrineExtensions\Query\Mysql\Least
lpad: DoctrineExtensions\Query\Mysql\Lpad
match_against: DoctrineExtensions\Query\Mysql\MatchAgainst
md5: DoctrineExtensions\Query\Mysql\Md5
nullif: DoctrineExtensions\Query\Mysql\NullIf
radians: DoctrineExtensions\Query\Mysql\Radians
regexp: DoctrineExtensions\Query\Mysql\Regexp
replace: DoctrineExtensions\Query\Mysql\Replace
rpad: DoctrineExtensions\Query\Mysql\Rpad
sha1: DoctrineExtensions\Query\Mysql\Sha1
sha2: DoctrineExtensions\Query\Mysql\Sha2
soundex: DoctrineExtensions\Query\Mysql\Soundex
substring_index: DoctrineExtensions\Query\Mysql\SubstringIndex
uuid_short: DoctrineExtensions\Query\Mysql\UuidShort
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
logging: true
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: dm\MembreBundle\Entity\Membre
jms_security_extra:
secure_all_services: true
knp_snappy:
pdf:
enabled: true
binary: wkhtmltopdf
options: []
image:
enabled: true
binary: wkhtmltoimage
options: []
oneup_uploader:
mappings:
filesDossier:
frontend: dropzone
namer: dm_foad.file_namer
filesSociete:
frontend: dropzone
namer: dm_foad.file_namer
oneup_flysystem:
adapters:
mylocal:
local:
directory: "%basePath%"
lazy: ~ # boolean (default "false")
writeFlags: ~
linkHandling: ~
permissions: ~
myftp:
ftp:
host: "%ftp_host%"
port: "%ftp_port%"
username: "%ftp_username%"
password: "%ftp_password%"
root: "%ftp_root%"
ssl: "%ftp_ssl%"
timeout: "%ftp_timeout%"
permPrivate: "%ftp_permPrivate%"
permPublic: "%ftp_permPublic%"
passive: "%ftp_passive%"
mysftp:
sftp:
host: "%sftp_host%"
port: "%sftp_port%"
username: "%sftp_username%"
password: "%sftp_password%"
root: "%sftp_root%"
timeout: "%sftp_timeout%"
permPrivate: "%sftp_permPrivate%"
permPublic: "%sftp_permPublic%"
directoryPerm: "%directoryPerm%"
filesystems:
mylocalfilesystem:
adapter: mylocal
myftpfilesystem:
adapter: myftp
mysftpfilesystem:
adapter: mysftp
config_dev.yml :
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
firephp:
type: firephp
level: info
chromephp:
type: chromephp
level: info
assetic:
use_controller: true
导航到您的应用配置文件。在树枝配置设置中(在树枝下:)你可以设置如下:
twig:
cache: false
默认设置为%kernel.cache_dir%/twig
,也许对你有帮助。
确保你禁用缓存仅在开发环境中!
实现此目的的简单方法是创建 config_dev.yml
,您只在其中保存 "overridden" 设置 dev
env
在config.yml
# Twig Configuration
twig:
#you other twig settings
cache: true
在config_dev.yml
中(在与config.yml相同的目录中)
# imports settgins from config.yml
imports:
- { resource: config.yml }
#override
twig:
cache: false
就是这样。
每次您使用 app_dev.php
访问您的应用时,来自 config_dev.yml
的设置将适用。
注意:您不必将所有设置复制到 config_dev
,只需复制您想要覆盖的设置
P.S。模式 config_name_<ENV>.yml
也适用于其他配置文件,而不仅仅是 config.yml
我正在使用 symfony 并按照有关使用 app_dev.php
工作的文档进行操作而不必担心缓存...但它对我不起作用。我经常被迫 clear_cache 查看我在 twig 模板中的更改!
我的 app_dev.php
:
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
//$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
如有任何帮助,我们将不胜感激。
[编辑]
config.yml :
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
framework:
#esi: ~
translator: { fallbacks: [%locale%] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
prod_server_url: "%prod_server_url%"
ovh_applicationSecret: "%ovh_applicationSecret%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
dql:
datetime_functions:
date: DoctrineExtensions\Query\Mysql\Date
date_format: DoctrineExtensions\Query\Mysql\DateFormat
dateadd: DoctrineExtensions\Query\Mysql\DateAdd
datesub: DoctrineExtensions\Query\Mysql\DateSub
datediff: DoctrineExtensions\Query\Mysql\DateDiff
day: DoctrineExtensions\Query\Mysql\Day
dayname: DoctrineExtensions\Query\Mysql\DayName
dayofweek: DoctrineExtensions\Query\Mysql\DayOfWeek
dayofyear: DoctrineExtensions\Query\Mysql\DayOfYear
div: DoctrineExtensions\Query\Mysql\Div
from_unixtime: DoctrineExtensions\Query\Mysql\FromUnixtime
last_day: DoctrineExtensions\Query\Mysql\LastDay
minute: DoctrineExtensions\Query\Mysql\Minute
now: DoctrineExtensions\Query\Mysql\Now
month: DoctrineExtensions\Query\Mysql\Month
monthname: DoctrineExtensions\Query\Mysql\MonthName
second: DoctrineExtensions\Query\Mysql\Second
strtodate: DoctrineExtensions\Query\Mysql\StrToDate
time: DoctrineExtensions\Query\Mysql\Time
timediff: DoctrineExtensions\Query\Mysql\TimeDiff
timestampadd: DoctrineExtensions\Query\Mysql\TimestampAdd
timestampdiff: DoctrineExtensions\Query\Mysql\TimestampDiff
week: DoctrineExtensions\Query\Mysql\Week
weekday: DoctrineExtensions\Query\Mysql\WeekDay
year: DoctrineExtensions\Query\Mysql\Year
yearweek: DoctrineExtensions\Query\Mysql\YearWeek
unix_timestamp: DoctrineExtensions\Query\Mysql\UnixTimestamp
numeric_functions:
acos: DoctrineExtensions\Query\Mysql\Acos
asin: DoctrineExtensions\Query\Mysql\Asin
atan2: DoctrineExtensions\Query\Mysql\Atan2
atan: DoctrineExtensions\Query\Mysql\Atan
bit_count: DoctrineExtensions\Query\Mysql\BitCount
bit_xor: DoctrineExtensions\Query\Mysql\BitXor
ceil: DoctrineExtensions\Query\Mysql\Ceil
cos: DoctrineExtensions\Query\Mysql\Cos
cot: DoctrineExtensions\Query\Mysql\Cot
floor: DoctrineExtensions\Query\Mysql\Floor
hour: DoctrineExtensions\Query\Mysql\Hour
pi: DoctrineExtensions\Query\Mysql\Pi
power: DoctrineExtensions\Query\Mysql\Power
quarter: DoctrineExtensions\Query\Mysql\Quarter
rand: DoctrineExtensions\Query\Mysql\Rand
round: DoctrineExtensions\Query\Mysql\Round
stddev: DoctrineExtensions\Query\Mysql\StdDev
sin: DoctrineExtensions\Query\Mysql\Sin
std: DoctrineExtensions\Query\Mysql\Std
tan: DoctrineExtensions\Query\Mysql\Tan
string_functions:
ascii: DoctrineExtensions\Query\Mysql\Ascii
binary: DoctrineExtensions\Query\Mysql\Binary
char_length: DoctrineExtensions\Query\Mysql\CharLength
concat_ws: DoctrineExtensions\Query\Mysql\ConcatWs
countif: DoctrineExtensions\Query\Mysql\CountIf
crc32: DoctrineExtensions\Query\Mysql\Crc32
degrees: DoctrineExtensions\Query\Mysql\Degrees
field: DoctrineExtensions\Query\Mysql\Field
find_in_set: DoctrineExtensions\Query\Mysql\FindInSet
group_concat: DoctrineExtensions\Query\Mysql\GroupConcat
ifelse: DoctrineExtensions\Query\Mysql\IfElse
ifnull: DoctrineExtensions\Query\Mysql\IfNull
least: DoctrineExtensions\Query\Mysql\Least
lpad: DoctrineExtensions\Query\Mysql\Lpad
match_against: DoctrineExtensions\Query\Mysql\MatchAgainst
md5: DoctrineExtensions\Query\Mysql\Md5
nullif: DoctrineExtensions\Query\Mysql\NullIf
radians: DoctrineExtensions\Query\Mysql\Radians
regexp: DoctrineExtensions\Query\Mysql\Regexp
replace: DoctrineExtensions\Query\Mysql\Replace
rpad: DoctrineExtensions\Query\Mysql\Rpad
sha1: DoctrineExtensions\Query\Mysql\Sha1
sha2: DoctrineExtensions\Query\Mysql\Sha2
soundex: DoctrineExtensions\Query\Mysql\Soundex
substring_index: DoctrineExtensions\Query\Mysql\SubstringIndex
uuid_short: DoctrineExtensions\Query\Mysql\UuidShort
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
logging: true
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: dm\MembreBundle\Entity\Membre
jms_security_extra:
secure_all_services: true
knp_snappy:
pdf:
enabled: true
binary: wkhtmltopdf
options: []
image:
enabled: true
binary: wkhtmltoimage
options: []
oneup_uploader:
mappings:
filesDossier:
frontend: dropzone
namer: dm_foad.file_namer
filesSociete:
frontend: dropzone
namer: dm_foad.file_namer
oneup_flysystem:
adapters:
mylocal:
local:
directory: "%basePath%"
lazy: ~ # boolean (default "false")
writeFlags: ~
linkHandling: ~
permissions: ~
myftp:
ftp:
host: "%ftp_host%"
port: "%ftp_port%"
username: "%ftp_username%"
password: "%ftp_password%"
root: "%ftp_root%"
ssl: "%ftp_ssl%"
timeout: "%ftp_timeout%"
permPrivate: "%ftp_permPrivate%"
permPublic: "%ftp_permPublic%"
passive: "%ftp_passive%"
mysftp:
sftp:
host: "%sftp_host%"
port: "%sftp_port%"
username: "%sftp_username%"
password: "%sftp_password%"
root: "%sftp_root%"
timeout: "%sftp_timeout%"
permPrivate: "%sftp_permPrivate%"
permPublic: "%sftp_permPublic%"
directoryPerm: "%directoryPerm%"
filesystems:
mylocalfilesystem:
adapter: mylocal
myftpfilesystem:
adapter: myftp
mysftpfilesystem:
adapter: mysftp
config_dev.yml :
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
firephp:
type: firephp
level: info
chromephp:
type: chromephp
level: info
assetic:
use_controller: true
导航到您的应用配置文件。在树枝配置设置中(在树枝下:)你可以设置如下:
twig:
cache: false
默认设置为%kernel.cache_dir%/twig
,也许对你有帮助。
确保你禁用缓存仅在开发环境中!
实现此目的的简单方法是创建 config_dev.yml
,您只在其中保存 "overridden" 设置 dev
env
在config.yml
# Twig Configuration
twig:
#you other twig settings
cache: true
在config_dev.yml
中(在与config.yml相同的目录中)
# imports settgins from config.yml
imports:
- { resource: config.yml }
#override
twig:
cache: false
就是这样。
每次您使用 app_dev.php
访问您的应用时,来自 config_dev.yml
的设置将适用。
注意:您不必将所有设置复制到 config_dev
,只需复制您想要覆盖的设置
P.S。模式 config_name_<ENV>.yml
也适用于其他配置文件,而不仅仅是 config.yml