Symfony 3 Fundamentals Bundles Configuration Environments
... the future:
Where do services come from?
Installing an external bundle
Configuring bundles
Controller outside services
Using config:dump-reference
Understanding Symfony environments
Create your own environment
The prod environment and cache:clear
The famous parameters.yml
Where do routes come from?
src/ versus app
Ready, set, go!
Logging and Adding other Tools
... composer require symfony/monolog-bundle:
While we're waiting, Google for "symfony monologbundle". The first link is to its
GitHub page, which basically just points
you to read the official documentation
on Symfony ...
Adding Routes Controllers
... can add routes,
controllers, translations, public assets, validation config and a bunch more!
Find your browser and Google for "Symfony bundle best practices". This is a really
nice document that talks about how you're ...
Flex Recipes
... of the recipes that
have been installed. And if you want more info about one, just run:
composer recipes symfony/twig-bundle
This is one of the recipes that was just executed. And ...
Finding and Instantiating the Controller
... inside FrameworkBundle. Open both
of them. The one in FrameworkBundle extends the other. See BaseControllerResolver
is the one that lives in the component:
// vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle ...
MakerBundle
For our last trick, I want to introduce a bundle that's going to make our life
awesome. And, for the first time, we are going to hook into Symfony.
First, find your terminal, and install that bundle ...
The HTTP Client Service
... install "just" a PHP library, it gives you PHP classes, but
it doesn't hook into Symfony to give you new services. What we just saw is a
special trick that many of the Symfony components use. The main bundle in our
app is ...
Upgrading to 2.2
... composer.json
file, being sure to only replace the core Symfony libraries, and not any
custom lines you may have added. In this case, the doctrine-fixtures-bundle
is custom, so I’ll leave it alone:
"require": {
},
Also, be sure ...
Fixing the First Deprecations
... WebServerBundle. That's now deprecated...
because the Symfony binary is shinier and more powerful.
So this deprecation is easy to fix. Inside composer.json, find the
symfony/web-server-bundle line:
Copy it, go to your terminal and ...
CI with Travis CI
... definitely
Travis CI. And if you go back to the "Best Practices" docs for bundles, near the
top, Symfony has an example of a robust Travis configuration file! Awesome!
Copy this entire thing, go back to the bundle, and ...
Publishing to Packagist
... Go to choosealicense.com and find the
license that works best for you. Symfony is licensed MIT, and that's definitely
the best practice. Whatever you choose, copy the license, find your bundle code,
and at the root ...
Installing Bundles with Average Docs
... .. but Symfony Flex, at least added it to bundles.php
for us. By the way, this is not necessarily a bad thing: sometimes a bundle doesn't
really need a custom recipe!
The second bundle did have a recipe. Before I started ...
Testing the Bundle
... bundle, the bundle itself
needs to require PHPUnit. Go back to the terminal and run:
composer require symfony/phpunit-bridge --dev
Two important things. First, we're using Symfony's ...
Bundles
... bundle? Very simply: bundles are Symfony plugins. They're
PHP libraries with special integration with Symfony.
And, the main reason that you add a bundle to your app is because bundles give you
services! In fact, every ...
Customizing Error Pages and How Errors are Handled
... in Path”. Let’s
look for the “An Error Occurred” text.
Ah hah! It points us straight to a file in the core Twig bundle called error.html.twig.
Let’s open that up!
Tip
The location of the file is:
vendor/symfony/symfony ...
Configuring Bundles
In the show controller, we're using two services: MarkdownParserInterface -
from a bundle we installed - and CacheInterface from Symfony itself:
And... this was pretty easy: add an argument with the right type-hint ...
Configuring a Bundle
... Let's dump this markdown object: I want to know exactly what this object actually
is: dump($markdown);die;:
Refresh the article page! Ok, it's an instance of some Max object - probably from
the bundle or some library ...
Adding a Cache Service
... caching is yet another tool that we need. If we had a service that was
really good at caching a string and letting us fetch it out later, that would be
perfect! Fortunately, Symfony comes with a bundle called ...
Bundles
... thanks to the recipe system, when we install a new bundle, that
bundle is automatically added to this file, which is how we already have 8 bundles
here. When we started our project, we only had 1!
So a bundle is a Symfony ...
Upgrading to Symfony 6.0
... ] requiring symfony/config ^3.4 || ^4.4 || ^5.1, but not
Symfony 6. So what's happening here? It turns out that pagerfanta-bundle[v2.8.0]
does not support Symfony 6. Gasp!
Run
composer ...
1534
symfony bundle
Filter Results