Symfony doesn’t care about your database or the code you use to talk to it. Most people that use Symfony use a third-party database library called Doctrine. Doctrine maps rows and columns in your database to objects and properties in PHP. Imagine we have an Event object with name and location properties. If we tell Doctrine to save this object, it inserts a row into a table and puts the data on name and location columns. And when we query for the event, it puts the column data back onto the properties of an Event object. When using Doctrine you need to stop thinking about tables, and start thinking about PHP classes. In this lesson, you will create the Event Entity Class, and learn a little debugging trick.
Additional resources
In this lesson, you will start using Doctrine to insert and query a database. First, you need to actually create and configure the database. Once we have that all set up, you will query the database, and render the results with Twig.
Additional resources
We’re using the built-in PHP web server, and it’s awesome for development. But it only handles one request at a time, so unless you only ever want one visitor, we’re going to need something different. To see how this might look, we’ll invent a fake domain, events.l
, and set it up to point to our project. I’ll use Apache, though it’s more and more common to use Nginx with PHP-FPM, because they’re lightning fast, but all the ideas are the same.
Additional resources
Now that we have an event page, we need our app to let users create, view, update and delete events. In other words, we need a CRUD for the Event entity. We can use Doctrine to generate a CRUD for us, but when it does that we need to clean a few things up since we've already been doing work in there. We'll also take a look at how to tighten up the generated code.
Additional resources
In this lesson, you'll use the assets:install command to get some nice CSS added to your application so we can make things look a little nicer.
We've got our Twig template files, and in this lesson we're going to take a closer look at working with creating links with the Twig path function, and making our dates make sense of the Twig date filter.
Additional resources
You may have heard some news about the fact that a new theme has been added to Drupal, named Classy. But what kind of theme is it exactly? Is it a pretty new look for Drupal 8? Well, no. You will still see Bartik as the default theme on your Drupal 8 site, so why another theme? Classy is a new base theme in core, which Bartik and Seven will then use as their bases. The idea here is to provide more flexibility to themers when it comes to choosing default CSS classes.
In this episode Kyle is joined by a few members of Lullabot's front-end army. Kris Bulman, Thomas Lattimore, Helena Zubkow, Marc Drummond, and Mike Herchel open up and discuss a project they have launched: The Front-End Rapport.
We built a nice, simple, easy-to-use site for our clients that gave them the tools they needed for discussions and a knowledge base. We set up a forum that displays only posts that are in the user’s language and a knowledge base book where all of the site members can create translations for the pages. The major need for this community was being able to use multiple languages and easily extend those languages in the future. Using Drupal’s core internationalization features with a handful of contributed modules, we have given them a very flexible multilingual solution. In this final lesson we'll tour the Blue Peak Fanatics site, discuss our implementation points, and review the modules and resources we used to build this site.
Additional resources
Using Drupal, 2nd edition
Using Drupal source code
Up next: Using Drupal Chapter 9: Online Store
There are a lot of tools available for working with multilingual sites, and we've implemented the main pieces we needed to build the site that Blue Peak Fanatics needs. In this lesson we'll take a look at some more modules we might consider down the road.
- Language icons
- Language switcher dropdown
- Transliteration
- Translation overview
- Translation table
Additional resources
The last little thing we need to do to clean up our site is to get our Home tab in the Main menu translated as well. Everything else in the menu is now translated, but the Home menu item isn't from one of the other features we've created. It's just a regular menu item. In this lesson we'll enable multilingual menus and get that home page tab translated.
Additional resources
When using Drupal’s taxonomy system, we need to find a way to sync the terms that we create to keep the taxonomy selection limited to just the terms for a given language. We don’t want all of the different languages showing up at the same time when someone is looking at a vocabulary or individual terms on the site. We're going to work with taxonomy to create our site's forum. The Forum module’s containers and forums structure is built on Drupal’s core taxonomy, so it is also creating a new vocabulary on our site. The forums on our client’s site need to display the threads that follow the same content selection rule as the rest of the content on the site. That is, we’ll only show the forum posts for the selected language. The site will have preset containers and forums, and then users may post to them using whichever language they choose.
Additional resources
We’ve translated the site name, but we still have other stubborn text on the site that we couldn't select on the Variable translation page. Our content types for the site are still using English for the content type name on the “Create content” page, and for field names when making new content. In this lesson, to fix this up, we'll walk through translating content type names, the Title label on the content type, and also see how to tackle the field labels as well.
Additional resources
Today we've got a bit of something for both site builders and developers: we'll wrap up our multilingual series based on Using Drupal, 2nd edition and release a brand new series of Symfony tutorials from our partners and PHP/Symfony training experts over at KnpUniversity.
Symfony Routing
FreeWhen you need a new page, you always start by creating a route: a chunk of configuration that gives that page a URL. In Symfony, all routes are configured in just one file: app/config/routing.yml. Your route was generated automatically when you created the EventBundle
. In this lesson we'll take a look at how this is working and explain basic routing concepts and route importing. We'll also dive into the _controller
syntax, routing parameters, and controller arguments.
Welcome to Symfony
FreeIf you'd like to learn Symfony 2 beyond what this introductory series offers, you should head over to KnpUniversity and check out their full catalog of Symfony 2 tutorials.
Additional resources
Symfony Bundles
FreeA bundle is just a place for us to store related code. We might make an EventBundle
directory for that feature, and a UserBundle
where we build the registration and login stuff. You can put anything and everything into a bundle: PHP code, config, templates, CSS and cats. You can also put other people’s bundles into your project. A bundle in Symfony is similar to a plugin in other systems. In this lesson you're going to create your first bundle, an EventBundle
, using the Symfony app console.
Getting down to the actual templates we want to render, we need to get a handle on Twig, a language that feels a lot like PHP, but was made specifically to be awesome at doing templating tasks, like looping, rendering other templates, and handling layouts. In this lesson, we'll go over the basic Twig tags, and extend a base layout to get our page looking the way we want.