As you use your form, you'll notice that after you submit the form, you just keep seeing the form again. If you keep submitting it, you'll end up with a bunch of duplicate records. That's no good. In this tutorial you will implement a redirect on the form submission to take the submitter to the home page, instead of back to the form, using the header()
function. We'll explain what exactly a header is and how that relates to our HTTP requests.
Our form is working well now, and to finish up, in this tutorial we're going to clean up and reorganize our code a little bit by moving things into a new custom function, called save_pets()
. This won't change how the form works, but moving logic into functions gives us two advantages, re-usable code, and making it clearer what the code we've written does, and is intended for.
Additional resources
Now that we've created a service, let's configure it. In this tutorial, you'll learn how to register your new service. We'll also be using Drupal Console to ensure everything is working as it should.
Note: The Drupal Console command container:debug
is now debug:container
.
Note: Drupal Console is no longer maintained. There are other tools and methods for getting a list of services in the container. See the tutorial Discover and Use Existing Services to learn more.
Additional resources
Discover and Use Existing Services
Dependency Injection and the Art of Services and Containers — Drupalize.Me
An Introduction to YAML — Drupalize.Me
In this lesson, you will learn how to get a Symfony 3 project started. First download Symfony and then follow along with this video tutorial.
Additional resources
Learn how to set up the IDE PhpStorm for Symfony 3 development. In this lesson, you'll install the Symfony plugin. You'll also want to install the PHP Annotations plugin in the same manner. Finally, you'll initialize a new Git repository on your system.
Additional resources
In this lesson you'll build your first page in Symfony 3. Be sure to download the code below so that you can follow along.
Tip: You should also find and install the PHP Annotations plugin. That will give you the awesome annotations auto-completion that you'll see in the video.
Additional resources
PHP Namespaces in 120 Seconds
PHP Namespaces Support in PhpStorm
PHP Annotations plugin for PhpStorm
In this lesson, learn how to make use of routing wildcards in a Symfony 3 app.
Additional resources
Be careful when rendering direct user input (like we show here)! It introduces a security issue called XSS. Read more about XSS here
In this lesson, learn how to use services and other useful objects like the service container in Symfony 3.
In this lesson, you'll learn how to find services you might want to use in the container by listing them.
In this lesson, you'll get a crash course in Twig. Covered here are the "say something" syntax, the "do something" syntax and for
loops. For broader coverage of Twig and the amazing things you can do with it, head over to the Twig Templating series.
Additional resources
In this lesson, you'll learn how to dress up the plain HTML that's being output in your Symfony app with a template layout using Twig's template inheritance feature. You'll learn how to use both block
and extends
Twig keywords to create, use, and re-use HTML layouts in your app. To explore more features in Twig, head over to the Twig Templating series.
Additional resources
In this lesson, you'll learn how to bring in CSS and JavaScript assets for use in the templates of your Symfony 3 app.
In this lesson, you'll learn how you can use Symfony 3 to create first-class APIs. We'll cover how to create endpoints, JSON controllers, and more.
PHP for Beginners Part 3
CourseWe already have a data source from PHP for Beginners Part 1 and PHP for Beginners Part 2 that makes our application dynamic. It reads and displays pet data, which happens to be stored in a file called pets.json. If we change something in this file, the site updates automatically. For a more complex site, however, we'll need to read and write a lot of data. So we're going to dive into the world of databases now and learn how to manage more data. This first tutorial covers database basics and how to connect and communicate with a MySQL database.
Additional resources
In this tutorial, now that we've connected to our database, we're going to learn the basics of SQL queries. You'll learn how to create databases, the tables that live in them, and how to do a basic SELECT query to retrieve information.
In this tutorial you'll get familiar with the INSERT and SELECT SQL commands to let you add and retrieve data from your database.
We're going to bring things together in this tutorial by finishing the basic queries of UPDATE and DELET, along with SHOW. Then we'll wrap things up by taking a look at the most popular MySQL GUI, phpMyAdmin.