File tree Expand file tree Collapse file tree 4 files changed +97
-3
lines changed Expand file tree Collapse file tree 4 files changed +97
-3
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,32 @@ Dotenv Component
4
4
Symfony Dotenv parses ` .env ` files to make environment variables stored in them
5
5
accessible via ` $_SERVER ` or ` $_ENV ` .
6
6
7
+ Getting Started
8
+ ---------------
9
+
10
+ ```
11
+ $ composer require symfony/dotenv
12
+ ```
13
+
14
+ ``` php
15
+ use Symfony\Component\Dotenv\Dotenv;
16
+
17
+ $dotenv = new Dotenv();
18
+ $dotenv->load(__DIR__.'/.env');
19
+
20
+ // you can also load several files
21
+ $dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev');
22
+
23
+ // overwrites existing env variables
24
+ $dotenv->overload(__DIR__.'/.env');
25
+
26
+ // loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
27
+ $dotenv->loadEnv(__DIR__.'/.env');
28
+ ```
29
+
7
30
Resources
8
31
---------
9
32
10
- * [ Documentation] ( https://symfony.com/doc/current/components/dotenv.html )
11
33
* [ Contributing] ( https://symfony.com/doc/current/contributing/index.html )
12
34
* [ Report issues] ( https://github.com/symfony/symfony/issues ) and
13
35
[ send Pull Requests] ( https://github.com/symfony/symfony/pulls )
Original file line number Diff line number Diff line change @@ -3,6 +3,35 @@ ErrorHandler Component
3
3
4
4
The ErrorHandler component provides tools to manage errors and ease debugging PHP code.
5
5
6
+ Getting Started
7
+ ---------------
8
+
9
+ ```
10
+ $ composer require symfony/error-handler
11
+ ```
12
+
13
+ ``` php
14
+ use Symfony\Component\ErrorHandler\Debug;
15
+ use Symfony\Component\ErrorHandler\ErrorHandler;
16
+ use Symfony\Component\ErrorHandler\DebugClassLoader;
17
+
18
+ Debug::enable();
19
+
20
+ // or enable only one feature
21
+ //ErrorHandler::register();
22
+ //DebugClassLoader::enable();
23
+
24
+ $data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) {
25
+ // if any code executed inside this anonymous function fails, a PHP exception
26
+ // will be thrown, even if the code uses the '@' PHP silence operator
27
+ $data = json_decode(file_get_contents($filename), true);
28
+ $data['read_at'] = date($datetimeFormat);
29
+ file_put_contents($filename, json_encode($data));
30
+
31
+ return $data;
32
+ });
33
+ ```
34
+
6
35
Resources
7
36
---------
8
37
Original file line number Diff line number Diff line change @@ -9,10 +9,33 @@ for changes. It also provides a concrete template engine implementation using
9
9
PHP with additional tools for escaping and separating templates into blocks and
10
10
layouts.
11
11
12
+ Getting Started
13
+ ---------------
14
+
15
+ ```
16
+ $ composer require symfony/templating
17
+ ```
18
+
19
+ ``` php
20
+ use Symfony\Component\Templating\Loader\FilesystemLoader;
21
+ use Symfony\Component\Templating\PhpEngine;
22
+ use Symfony\Component\Templating\Helper\SlotsHelper;
23
+ use Symfony\Component\Templating\TemplateNameParser;
24
+
25
+ $filesystemLoader = new FilesystemLoader(__DIR__.'/views/%name%');
26
+
27
+ $templating = new PhpEngine(new TemplateNameParser(), $filesystemLoader);
28
+ $templating->set(new SlotsHelper());
29
+
30
+ echo $templating->render('hello.php', ['firstname' => 'Fabien']);
31
+
32
+ // hello.php
33
+ Hello, <?= $view->escape($firstname) ?>!
34
+ ```
35
+
12
36
Resources
13
37
---------
14
38
15
- * [ Documentation] ( https://symfony.com/doc/current/components/templating.html )
16
39
* [ Contributing] ( https://symfony.com/doc/current/contributing/index.html )
17
40
* [ Report issues] ( https://github.com/symfony/symfony/issues ) and
18
41
[ send Pull Requests] ( https://github.com/symfony/symfony/pulls )
Original file line number Diff line number Diff line change @@ -8,10 +8,30 @@ This component implements the [HTML5's Links](https://www.w3.org/TR/html5/links.
8
8
and [ Resource Hints] ( https://www.w3.org/TR/resource-hints/ ) W3C's specifications.
9
9
It can also be used with extensions defined in the [ HTML5 link type extensions wiki] ( http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions ) .
10
10
11
+ Getting Started
12
+ ---------------
13
+
14
+ ```
15
+ $ composer require symfony/web-link
16
+ ```
17
+
18
+ ``` php
19
+ use Symfony\Component\WebLink\GenericLinkProvider;
20
+ use Symfony\Component\WebLink\HttpHeaderSerializer;
21
+ use Symfony\Component\WebLink\Link;
22
+
23
+ $linkProvider = (new GenericLinkProvider())
24
+ ->withLink(new Link('preload', '/bootstrap.min.css'));
25
+
26
+ header('Link: '.(new HttpHeaderSerializer())->serialize($linkProvider->getLinks()));
27
+
28
+ echo 'Hello';
29
+ ```
30
+
11
31
Resources
12
32
---------
13
33
14
- * [ Documentation] ( https://symfony.com/doc/current/components/ web_link.html )
34
+ * [ Documentation] ( https://symfony.com/doc/current/web_link.html )
15
35
* [ Contributing] ( https://symfony.com/doc/current/contributing/index.html )
16
36
* [ Report issues] ( https://github.com/symfony/symfony/issues ) and
17
37
[ send Pull Requests] ( https://github.com/symfony/symfony/pulls )
You can’t perform that action at this time.
0 commit comments