Any information on how to use symfony's decoupled components?
I'm rereading the docs but there's nothing on the topic besides a general message of "They are very very decoupled" and 1 tutorial that makes use of Request and Response.
There's also one badly ranked answer of Using symfony2 routing component (outside of symfony2)
Also having a look at a tutorial for the standalone Form component doesn't actually excite me how pleasant this is.
I need the routing, yaml, and session.
The first component you should use is ClassLoader. You can also use spl_autoload_register, but you're using Symfony, so why shouldn't you use its own autoloading library? Add the following at the top of the script:
use Symfony\Component\ClassLoader\UniversalClassLoader;
require_once '/path/to/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new UniversalClassLoader();
$loader->register();
$loader->registerNamespaces(array(
'Symfony' => '/path/to/symfony/src',
));
Using the Yaml component is really easy:
use Symfony\Component\Yaml\Parser;
$data = Parser::parse('yaml string');
For the other components, you'll have to read the API documentation, as there are no tutorials yet.
Interestingly, Fabien Potencier just published a blog post which contains snippets of how to use the most common components. See the second half of this post for details.
I've written a tutorial which might help you, on using decoupled Symfony components in your project.
It shows how to use the console component as an example, but the logic is the same for other components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With