Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
This tutorial has a new version, check it out!

The Symfony Micro-Framework

37:26

What you'll be learning

// composer.json
{
    "require": {
        "symfony/symfony": "^2.7", // v2.7.2
        "sensio/framework-extra-bundle": "^3.0", // v3.0.9
        "vlucas/phpdotenv": "^2.0", // v2.0.1
        "symfony/monolog-bundle": "^2.7" // v2.7.1
    }
}

NOTE Symfony 4 makes this course deprecated this course, as it is itself a micro framework! In fact, several of the things done in this tutorial were adopted in the core of Symfony. So, stay tuned! Or, watch this tutorial to learn more about the depths of Symfony.

So you love microframeworks like Silex. Yep - me too. Being able to create a single file and immediately code up some routes is awesome.

But Symfony is a big framework, right? Wrong! Symfony can be as small as a single file!

In this tutorial, we'll bootstrap a project using Symfony as a micro-framework: something that looks more like Silex, but with the tools you're used to. This means:

  • Small: A project structure with very few files
  • Simple: Create pages by touching one file
  • Familiar: It's still Symfony :)
  • Powerful: Enable/disable any bundles you need
  • Evolve: Grow from micro to full-sized as your app succeeds

So if your next project is perfect for a micro-framework, you can still use Symfony.

Oh, and thanks to Benjamin Eberlei for his blog post and work - Symfony All The Things (Web) that served as motivation.


Your Guides

Ryan Weaver Leanna Pelham

Buy Access

Join the Conversation?

4
Login or Register to join the conversation
JuanLuisGarciaBorrego Avatar
JuanLuisGarciaBorrego Avatar JuanLuisGarciaBorrego | posted 5 years ago

Hello, Ryan!
A dude.., the version of symfony 2.8 that comes with the option of micro-framework that is like this?

This ready to use or you have to shape it as in this tutorial?

Another question, if I want to put here ORM doctrine, as you would?

Thank you

Greetins

Reply

Hey Juan!

Sorry for the late reply - SymfonyCon key me busy last week :). Symfony 2.8 comes with the MicroKernelTrait (obviously), but there is no official starting "project" (like the Symfony Standard Edition) that uses the MicroKernelTrait out of the box. I assume that some community member will probably support this. I don't know if there will ever be an official version, as it's sometimes difficult if you give people (especially beginners) too many options :). Here is an example starting project using it: https://github.com/CawaKhar...

To include Doctrine ORM, what you would need to do is:

1) Add DoctrineBundle to your kernel
2) Configure it. That basically means, somehow include the normal "doctrine" config.yml configuration in your project.
3) Have a bundle. On this project, I never include a bundle. But, it's much easier to use Doctrine if you have an AppBundle :).

Cheers!

Reply
JuanLuisGarciaBorrego Avatar
JuanLuisGarciaBorrego Avatar JuanLuisGarciaBorrego | weaverryan | posted 5 years ago

No problem, I know your were in SymfonyCon =), good slides!!
As it will be as Silex, when our app grow ... we need to configure it.

Thanks for you reply.
greetins!

Reply

Ha yes, you understand it perfectly :). Cheers!

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

userVoice