Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49f1d9b

Browse files
committed
Added config reference too!
1 parent 96768df commit 49f1d9b

File tree

1 file changed

+129
-118
lines changed

1 file changed

+129
-118
lines changed

reference/configuration/framework.rst

Lines changed: 129 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,11 @@ doubling them to prevent Symfony from interpreting them as container parameters)
454454
.. code-block:: php
455455
456456
// config/packages/framework.php
457-
$container->loadFromExtension('framework', [
458-
'ide' => 'myide://open?url=file://%%f&line=%%l',
459-
]);
457+
use Symfony\Config\FrameworkConfig;
458+
459+
return static function (FrameworkConfig $framework) {
460+
$framework->ide('myide://open?url=file://%%f&line=%%l');
461+
};
460462
461463
Since every developer uses a different IDE, the recommended way to enable this
462464
feature is to configure it on a system level. This can be done by setting the
@@ -596,9 +598,11 @@ the application won't respond and the user will receive a 400 response.
596598
.. code-block:: php
597599
598600
// config/packages/framework.php
599-
$container->loadFromExtension('framework', [
600-
'trusted_hosts' => ['^example\.com$', '^example\.org$'],
601-
]);
601+
use Symfony\Config\FrameworkConfig;
602+
603+
return static function (FrameworkConfig $framework) {
604+
$framework->trustedHosts(['^example\.com$', '^example\.org$']);
605+
};
602606
603607
Hosts can also be configured to respond to any subdomain, via
604608
``^(.+\.)?example\.com$`` for instance.
@@ -724,9 +728,11 @@ You can also set ``esi`` to ``true`` to enable it:
724728
.. code-block:: php
725729
726730
// config/packages/framework.php
727-
$container->loadFromExtension('framework', [
728-
'esi' => true,
729-
]);
731+
use Symfony\Config\FrameworkConfig;
732+
733+
return static function (FrameworkConfig $framework) {
734+
$framework->esi()->enabled(true);
735+
};
730736
731737
fragments
732738
~~~~~~~~~
@@ -1359,13 +1365,12 @@ To configure a ``jsonp`` format:
13591365
.. code-block:: php
13601366
13611367
// config/packages/framework.php
1362-
$container->loadFromExtension('framework', [
1363-
'request' => [
1364-
'formats' => [
1365-
'jsonp' => 'application/javascript',
1366-
],
1367-
],
1368-
]);
1368+
use Symfony\Config\FrameworkConfig;
1369+
1370+
return static function (FrameworkConfig $framework) {
1371+
$framework->request()
1372+
->format('jsonp', 'application/javascript');
1373+
};
13691374
13701375
router
13711376
~~~~~~
@@ -1720,11 +1725,12 @@ setting the value to ``null``:
17201725
.. code-block:: php
17211726
17221727
// config/packages/framework.php
1723-
$container->loadFromExtension('framework', [
1724-
'session' => [
1725-
'save_path' => null,
1726-
],
1727-
]);
1728+
use Symfony\Config\FrameworkConfig;
1729+
1730+
return static function (FrameworkConfig $framework) {
1731+
$framework->session()
1732+
->savePath(null);
1733+
};
17281734
17291735
.. _reference-session-metadata-update-threshold:
17301736

@@ -1774,11 +1780,12 @@ Whether to enable the session support in the framework.
17741780
.. code-block:: php
17751781
17761782
// config/packages/framework.php
1777-
$container->loadFromExtension('framework', [
1778-
'session' => [
1779-
'enabled' => true,
1780-
],
1781-
]);
1783+
use Symfony\Config\FrameworkConfig;
1784+
1785+
return static function (FrameworkConfig $framework) {
1786+
$framework->session()
1787+
->enabled(true);
1788+
};
17821789
17831790
use_cookies
17841791
...........
@@ -1830,12 +1837,13 @@ This option allows you to define a base path to be used for assets:
18301837
.. code-block:: php
18311838
18321839
// config/packages/framework.php
1833-
$container->loadFromExtension('framework', [
1840+
use Symfony\Config\FrameworkConfig;
1841+
1842+
return static function (FrameworkConfig $framework) {
18341843
// ...
1835-
'assets' => [
1836-
'base_path' => '/images',
1837-
],
1838-
]);
1844+
$framework->assets()
1845+
->basePath('/images');
1846+
};
18391847
18401848
.. _reference-templating-base-urls:
18411849
.. _reference-assets-base-urls:
@@ -1879,12 +1887,13 @@ collection each time it generates an asset's path:
18791887
.. code-block:: php
18801888
18811889
// config/packages/framework.php
1882-
$container->loadFromExtension('framework', [
1890+
use Symfony\Config\FrameworkConfig;
1891+
1892+
return static function (FrameworkConfig $framework) {
18831893
// ...
1884-
'assets' => [
1885-
'base_urls' => ['http://cdn.example.com/'],
1886-
],
1887-
]);
1894+
$framework->assets()
1895+
->baseUrls(['http://cdn.example.com/']);
1896+
};
18881897
18891898
.. _reference-framework-assets-packages:
18901899

@@ -1928,16 +1937,14 @@ You can group assets into packages, to specify different base URLs for them:
19281937
.. code-block:: php
19291938
19301939
// config/packages/framework.php
1931-
$container->loadFromExtension('framework', [
1940+
use Symfony\Config\FrameworkConfig;
1941+
1942+
return static function (FrameworkConfig $framework) {
19321943
// ...
1933-
'assets' => [
1934-
'packages' => [
1935-
'avatars' => [
1936-
'base_urls' => 'http://static_cdn.example.com/avatars',
1937-
],
1938-
],
1939-
],
1940-
]);
1944+
$framework->assets()
1945+
->package('avatars')
1946+
->baseUrls(['http://static_cdn.example.com/avatars']);
1947+
};
19411948
19421949
Now you can use the ``avatars`` package in your templates:
19431950

@@ -2005,12 +2012,13 @@ Now, activate the ``version`` option:
20052012
.. code-block:: php
20062013
20072014
// config/packages/framework.php
2008-
$container->loadFromExtension('framework', [
2015+
use Symfony\Config\FrameworkConfig;
2016+
2017+
return static function (FrameworkConfig $framework) {
20092018
// ...
2010-
'assets' => [
2011-
'version' => 'v2',
2012-
],
2013-
]);
2019+
$framework->assets()
2020+
->version('v2');
2021+
};
20142022
20152023
Now, the same asset will be rendered as ``/images/logo.png?v2`` If you use
20162024
this feature, you **must** manually increment the ``version`` value
@@ -2132,25 +2140,25 @@ individually for each asset package:
21322140
.. code-block:: php
21332141
21342142
// config/packages/framework.php
2135-
$container->loadFromExtension('framework', [
2136-
'assets' => [
2137-
'version_strategy' => 'app.asset.my_versioning_strategy',
2138-
'packages' => [
2139-
'foo_package' => [
2140-
// this package removes any versioning (its assets won't be versioned)
2141-
'version' => null,
2142-
],
2143-
'bar_package' => [
2144-
// this package uses its own strategy (the default strategy is ignored)
2145-
'version_strategy' => 'app.asset.another_version_strategy',
2146-
],
2147-
'baz_package' => [
2148-
// this package inherits the default strategy
2149-
'base_path' => '/images',
2150-
],
2151-
],
2152-
],
2153-
]);
2143+
use Symfony\Config\FrameworkConfig;
2144+
2145+
return static function (FrameworkConfig $framework) {
2146+
// ...
2147+
$framework->assets()
2148+
->versionStrategy('app.asset.my_versioning_strategy');
2149+
2150+
$framework->assets()->package('foo_package')
2151+
// this package removes any versioning (its assets won't be versioned)
2152+
->version(null);
2153+
2154+
$framework->assets()->package('bar_package')
2155+
// this package uses its own strategy (the default strategy is ignored)
2156+
->versionStrategy('app.asset.another_version_strategy');
2157+
2158+
$framework->assets()->package('baz_package')
2159+
// this package inherits the default strategy
2160+
->basePath('/images');
2161+
};
21542162
21552163
.. note::
21562164

@@ -2229,24 +2237,24 @@ package:
22292237
.. code-block:: php
22302238
22312239
// config/packages/framework.php
2232-
$container->loadFromExtension('framework', [
2233-
'assets' => [
2240+
use Symfony\Config\FrameworkConfig;
2241+
2242+
return static function (FrameworkConfig $framework) {
2243+
// ...
2244+
$framework->assets()
22342245
// this manifest is applied to every asset (including packages)
2235-
'json_manifest_path' => '%kernel.project_dir%/public/build/manifest.json',
2236-
// you can use absolute URLs too and Symfony will download them automatically
2237-
// 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
2238-
'packages' => [
2239-
'foo_package' => [
2240-
// this package uses its own manifest (the default file is ignored)
2241-
'json_manifest_path' => '%kernel.project_dir%/public/build/a_different_manifest.json',
2242-
],
2243-
'bar_package' => [
2244-
// this package uses the global manifest (the default file is used)
2245-
'base_path' => '/images',
2246-
],
2247-
],
2248-
],
2249-
]);
2246+
->jsonManifestPath('%kernel.project_dir%/public/build/manifest.json');
2247+
2248+
// you can use absolute URLs too and Symfony will download them automatically
2249+
// 'json_manifest_path' => 'https://cdn.example.com/manifest.json',
2250+
$framework->assets()->package('foo_package')
2251+
// this package uses its own manifest (the default file is ignored)
2252+
->jsonManifestPath('%kernel.project_dir%/public/build/a_different_manifest.json');
2253+
2254+
$framework->assets()->package('bar_package')
2255+
// this package uses the global manifest (the default file is used)
2256+
->basePath('/images');
2257+
};
22502258
22512259
.. versionadded:: 5.1
22522260

@@ -2335,11 +2343,12 @@ performance a bit:
23352343
.. code-block:: php
23362344
23372345
// config/packages/translation.php
2338-
$container->loadFromExtension('framework', [
2339-
'translator' => [
2340-
'enabled_locales' => ['en', 'es'],
2341-
],
2342-
]);
2346+
use Symfony\Config\FrameworkConfig;
2347+
2348+
return static function (FrameworkConfig $framework) {
2349+
$framework->translator()
2350+
->enabledLocales(['en', 'es']);
2351+
};
23432352
23442353
If some user makes requests with a locale not included in this option, the
23452354
application won't display any error because Symfony will display contents using
@@ -2621,15 +2630,13 @@ the component will look for additional validation files:
26212630
.. code-block:: php
26222631
26232632
// config/packages/framework.php
2624-
$container->loadFromExtension('framework', [
2625-
'validation' => [
2626-
'mapping' => [
2627-
'paths' => [
2628-
'%kernel.project_dir%/config/validation/',
2629-
],
2630-
],
2631-
],
2632-
]);
2633+
use Symfony\Config\FrameworkConfig;
2634+
2635+
return static function (FrameworkConfig $framework) {
2636+
$framework->validation()
2637+
->mapping()
2638+
->paths(['%kernel.project_dir%/config/validation/']);
2639+
};
26332640
26342641
annotations
26352642
~~~~~~~~~~~
@@ -2927,16 +2934,14 @@ To configure a Redis cache pool with a default lifetime of 1 hour, do the follow
29272934
.. code-block:: php
29282935
29292936
// config/packages/framework.php
2930-
$container->loadFromExtension('framework', [
2931-
'cache' => [
2932-
'pools' => [
2933-
'cache.mycache' => [
2934-
'adapter' => 'cache.adapter.redis',
2935-
'default_lifetime' => 3600,
2936-
],
2937-
],
2938-
],
2939-
]);
2937+
use Symfony\Config\FrameworkConfig;
2938+
2939+
return static function (FrameworkConfig $framework) {
2940+
$framework->cache()
2941+
->pool('cache.mycache')
2942+
->adapters(['cache.adapter.redis'])
2943+
->defaultLifetime(3600);
2944+
};
29402945
29412946
.. _reference-cache-pools-name:
29422947

@@ -3094,9 +3099,12 @@ A list of lock stores to be created by the framework extension.
30943099
.. code-block:: php
30953100
30963101
// config/packages/lock.php
3097-
$container->loadFromExtension('framework', [
3098-
'lock' => '%env(LOCK_DSN)%',
3099-
]);
3102+
use Symfony\Config\FrameworkConfig;
3103+
3104+
return static function (FrameworkConfig $framework) {
3105+
$framework->lock()
3106+
->resource('lock', ['%env(LOCK_DSN)%']);
3107+
};
31003108
31013109
.. seealso::
31023110

@@ -3281,11 +3289,14 @@ A list of workflows to be created by the framework extension:
32813289
.. code-block:: php
32823290
32833291
// config/packages/workflow.php
3284-
$container->loadFromExtension('framework', [
3285-
'workflows' => [
3286-
'my_workflow' => // ...
3287-
],
3288-
]);
3292+
use Symfony\Config\FrameworkConfig;
3293+
3294+
return static function (FrameworkConfig $framework) {
3295+
$framework->workflows()
3296+
->workflows('my_workflow')
3297+
// ...
3298+
;
3299+
};
32893300
32903301
.. seealso::
32913302

0 commit comments

Comments
 (0)