If you using Windows to follow along, there are a couple things you should be aware of when installing CakePHP 2. In this training video, you will learn how to check if PHP needs to be added to the path environment variable, as well as how to configure PHP to the command line.
- In this course, the author Justin Yost will be demonstrating how to install and configure CakePHP2 using a Macintosh. If you're following along on a windows machine, there are only two small notes you need to be aware of. The first is the PHP must be able to run at the command line, because PHP is typically run at the command line. This can be checked by typing php -v into a command prompt. Also make sure to use backslashes for file paths. So when the author is using forward slashes, to start a server for example, make sure that you are using backslashes so that the command prompt knows exactly where to look for those files.
To check whether PHP is available at the command line, I'm going to hit the windows key and R to invoke the run dialogue. Typing in cmd and pressing enter will present us with a command prompt. I'm going to type php -v to check if php is available. If you see a message that says php is not recognized as an internal or external command, it means that php needs to be added to the path environment variable before it can be used at the command line level.
I'm going to close the command prompt, and right clicking on the start button, I'm going to choose system, and then, from the system control panel choose advanced system settings from the left hand column. From the system propertis window in the advanced tab, all the way at the bottom, I'm going to choose environment variables. Inside the environment variables window, we want to be careful to only make the changes that we need. I'm going to select the path variable, under system variables, but before we add the location to PHP, we need to know where it is.
On this sytem, I'm using wamp to provide and apache server, my sequel, and PHP. Within the wamp folder, under bin, php, is a specific folder for the version of PHP, which wamp has installed. Inside you should see the php application itself. I'm going to go ahead and copy this path, and you should copy the path to wherever php is installed for you. Then I'm going to click edit to edit the path variable.
At the very end of the variable value I'm going to add a semi-colon, and then paste in the location to php. Then click ok. If you make any mistakes at this point, go ahead and click cancel to make sure that none of your system values are changed. Since we've only changed the path we need, I'm going to click ok, and close the various setting windows as well as the php 5.5.12 window. Hitting windows key, R, and then pressing enter to open the command prompt again, I'm going to type php -v, and now we can the at PHP 5.5.12 is available from the command line.
CakePHP is a critical framework for PHP developers. It helps them build complex web applications faster and more efficiently than coding by hand. If you want to use CakePHP in your own development workflow, this is the place to start. Justin Yost provides an overview of the underlying MVC pattern in CakePHP, and the installation and configuration process for the framework. He shows how to use CakePHP shells and the console to build your first basic CakePHP app, and then discusses each application element in depth: controllers, models, views, components, behaviors, helpers, and utilities.
In later chapters the course gets a little more advanced. Watch these videos to learn how to write a custom shell, extend CakePHP with plugins, and write unit tests to identify and eliminate bugs in your code. Justin also shows how to add security to your CakePHP apps with a basic user authentication system.
NOTE: While CakePHP 2 is a slightly older version of the framework, it's still an actively developed tool that is useful for maintaining and updating web applications. Many of the conventions and problem-solving approaches in this course are also applicable to CakePHP 3.
- Comparing CakePHP 2 and CakePHP 3
- Installing and configuring CakePHP
- Using different CakePHP shells
- Creating CakePHP controllers
- Saving data in a CakePHP model
- Creating views
- Using components to share functionality between controllers
- Using behaviors
- Formatting data with helpers
- Developing faster with CakePHP utilities
- Writing a custom CakePHP shell
- Creating a custom plugin
- Testing CakePHP applications
- Authorizing users of CakePHP applications