Join Jon Peck for an in-depth discussion in this video Exercise files, part of Up and Running with Symfony2 for PHP (2014).
- In this course, I'm going to be developing in a local PHP environment using Symfony Standard Edition 2.5 as the framework, PHP 5.5 as the server-side language, MySQL 5.5 as the database server, and Apache 2.4 as the web server. Other web servers such as Nginx or IIS won't be covered within the scope of this course, but they should work. If you don't already have a server for development, I recommend using a local development server running on your work station. In this course, I'm going to be demonstrating using a virtualized server running in my existing operating system.
If you'd like a server configured using this technique, check out Up and Running with Linux for PHP Developers here in the Lynda.com online training library. You can also use a web server solution stack package in your native operating system. XAMPP from apachefriends.org has distributions for every major platform. WampServer from wampserver.com is explicitly for Windows and MAMP from mamp.info is designed for Macs. Each of these packages will allow you to run the exercises found in this course.
Installing additional software within your native operating system is covered in the course Installing Apache, MySQL, and PHP with David Gassner here in the Lynda.com online training library. Regardless of the location of your web server, you'll need access to the commands line with administrative credentials in order to install and configure server software. For Mac and Linux, the terminal allows you to access the commands line, which includes access to the SSH command if the site is hosted remotely. For Windows, you can use the free program PuTTY to connect via SSH remote servers available from the official PuTTY website.
I'm going to be demonstrating writing code using NetBeans IDE version eight for PHP. NetBeans is a free, open source, and cross-platform integrated development environment from netbeans.org. The goal of the course is to use Symfony, not how to use NetBeans, but with that said, I'm only going to be editing code in NetBeans. Any IDE or text editor will work. The exercise files for this course are contained in folders by chapter and movie. On my work station, I have them in a folder named Sandbox that my virtualized Linux server can access.
Depending on your web server configuration, you may need to store these files in a different place such as a remote web server or in a folder accessible by local Apache and PHP Stack. I'm including an additional folder called Assets, which contains images for testing uploading during the course. A final note, as different web hosts and configurations serve content from different URLs, the addresses you see in my browser may not exactly match what you see on your work station. Additionally, the locations shown in the command prompt demonstrations will differ depending on the location of side files and configurations of your server.
With that said, the software configuration will be very similar, if not identical across all platforms. Don't worry, you'll be fine.
- Installing Symfony
- Creating a bundle from the console
- Customizing and generating database tables
- Generating controllers
- Creating, editing, and debugging entities
- Displaying and debugging a form
- Rendering content with templates
Skill Level Intermediate
Q: When trying to access the application, I receive an error stating "This script is only accessible from localhost." How can I get around this restriction?
A: The development front controller and configuration scripts are protected by default to only allow access from the localhost. Refer to the video titled “Exploring the Symfony layout” to see how to disable this security.
Q: I specified the wrong database credentials and got an "Access denied for user" error from doctrine. How can I fix the database configuration?
<div>A: The most likely cause is a typo or misconfiguration in the Symfony parameters file, which you can find at ./symfony/app/config/parameters.yml. This file is typically generated during installation using an interactive wizard.</div><div> </div><div>Symfony requires read and write access to a MySQL database, and needs to know how to connect to the database. Therefore, you'll need to specify a username, password, port (if nonstandard), host, and database name. The credentials to your individual development environment are likely different than the ones used in the course; please use your best judgment in determining the correct values. After making a change, verify the configuration by using a web browser to navigate to /symfony/web/config.php, then click “Configure your Symfony Application online” at the bottom of the page.</div>
Q: How can I configure PHP's time zone?
<div>A: You'll need to edit PHP's configuration to specify a time zone. The <em></em><a href="http://www.lynda.com/Apache-tutorials/Up-Running-Linux-PHP-Developers/158372-2.html"><em>Up and Running with Linux for PHP</em> <em>Developers</em></a> PHP configuration can be modified by editing the custom configuration:</div><div> </div><div>sudoedit /etc/php5/mods-available/custom.ini</div><div> </div><div> If you have a different development environment, determine the location of your php.ini configuration file. Specify a date.timezone, such as: </div><div> </div><div>date.timezone = America/Los_Angeles</div><div> </div><div>Then restart the server using: </div><div> </div><div>sudo service apache2 restart</div><div> </div><div>A full list of supported timezones can be found at <a target="_blank" href="http://php.net/manual/en/timezones.php">http://php.net/manual/en/timezones.php</a>.</div><div> </div>