In this course I will teach you from the ground floor how to build an application in PHP's fastest full-scale framework; PhalconPHP. Controllers, Views, Routes, Templates, Models/Relationships/ORM; All covered.
Each section is broken down for you to follow along with and write code as I do. After learning as you go, we'll create a project based on what you've learned.
We will make changes to the Bootstrap through each step in this follow-along series so you know exactly what's going on. This course is geared towards the medium to advanced skilled developer who have a well rounded knowledge of PHP and Object Oriented Design.
This course should take you around 2-3 weeks to complete, but you may need to come back a few times in order to absorb all the material. You should consider taking this course if you are interested in advanced development and bleeding-edge technology that will dominate PHP.
PhalconPHP is the fastest full-scale framework written in C for the Zend Engine.
This demonstrates how to properly install Phalcon. It's similar to almost any MVC besides the extension adding. I'll show you how to create a Virtual Host to protect non-public files.
We will create a directory structure like the Phalcon Documents use to stay consistent with them. Yet the option is still up to you to lay it out anyway you choose.
I will also be using GIT for managing this project and I encourage you to if you know how to use it. The purpose of me bringing it up is so that you are not confused about any .git folders and files.
The Bootstrap is the entry point for the application. This is where you define autoloading, view folders, and return data from the application.
The DependencyInjector is like a global registry using closures, it will become very useful in the future.
Although a CLI application can generate this for us, it's important you understand what's going on.
Learn a few core items that are important for the Controller.
- With the Dispatcher ($this->dispatch->forward) you can call another URL action (as if it were a function).
- With the initialize() function, you can use it for protecting your Routes.
- initialize() is only called When a route is successfully loaded (beforeExecuteRoute)
Learn how to render your views from controllers, and how to take advantage of layouts.
Important: If create /layout/login.phtml Phalcon will autoload for the login controller, so you do not need to call setTemplateAfter('login') or it will load twice.
View Render Levels
Follow along to create our database schema if you like. I will be using HeidiSQL (free), you may use your favorite SQL client.
Place our database connection into the application using the Dependency Injector.
Learn how to Create, Update, and Select data.
Learn how to delete data permanently and soft deleting.
Events can be used to add repetitive tasks to your query, validate data, or call out other methods.
Additionally there are these model methods: beforeDelete() and afterDelete();
Learn how to associate your models with other tables. We will use the Model::hasMany() and Model::belongsTo().
There are two other features I won't be convering (hasOne and hasManyToMany), you can look those up in the docs (see link).
Easily add to another table with associated records with a few lines of code.
I demonstrate the save() feature, but you can also use this for updating and deleting.
APC is an "Alternative PHP Cache" library. This is how you install it on Debian/Ubuntu systems using PEAR.
Here is how you install APC for usage on Windows inside of WAMP or XAMPP.
MediaFire Link: For 64-Bit PHP (php_apc-3.1.13-5.4-VC9-x64.zip)
PHP.net Link: For 32-Bit PHP (php_apc-3.1.10-5.4-vc9-x86.zip)
Note: PHP Suggests using code compiled with VC9 over VC6 for increased performance.
MetaData is a description of your SQL table to map it to your Model file in the ORM. It's going to save your server load time by caching your table meta-data so you do not waste query(s) on every model instantiation.
How to use the request environment.
There are a lot of features to the routes. I will show the basics
and the two main options you might want to use.
We will use the Assets manager briefly for loading Js or CSS into our views. Ill also show you the collections, and there are further options for minification you can find in the documents.
We'll also create a BaseController to make our project easier to manage with shared functionality when need-be.
The Volt template engine is quite snazzy and similar to Mustache or Jinja Templating. We just load up the one liner into our view injection and we are good to go.
The Volt Templating engine is extremely easy to use. I'll show you some basics as we rewrite our user view into Volt.
We begin our application titled "Fireball". We will do a major facelift and clean up a lot of the learning code, and setup a base template system while integrating Bootstrap 3. You may skip this video if you like and just download the code and continue, however, I recommend watching at the very least so you pickup some tricks.
We touch base to see if you followed along :)
We begin setting up an ACL System (Access Control List). For Guests, Users, and Admins. there is a lot of code we type to set it up, so I have provided the files in case you make a mistake.
Here we finish adding permissions to our ACL with our different groups. We run into a few kinks in the road, please just watch to get a few ideas on debugging. There is a lot of code to type so I've provided the files incase you have any problems.
Learn how to flash data when a user isn't allowed somewhere. Then refactor some of our namespaces for cleanliness.
We begin to tie in the login form with the ACL and a user dashboard page.
We finish to tie in the login form with the ACL and a user dashboard page.
Use the security class for CSRF and Encrpyting Passwords. You need OpenSSL Enabled.
Cram Session to build out the registration in one sitting!
A handy class to pass configurations around your system.
Custom components are an elegant way to make re-usable code with access to all dependency inejected object.
Using Composer with Phalcon (Or any other system for that matter) is extremely simple, and it manages dependencies nicely!
Setup a Vagrant Box with: PHP 5.5, MySQL 5.5, Redis Server, Phalcon, Phalcon Dev Tools, Git and Composer to work along with me.
We point Apache to our own folder to work in.
Please see the attached instructions if you get stuck.
Migrations are used to update your database from local to production on the fly after making changes without having to do everything by hand or touch SQL code.
Scaffolding creates a quick CRUD interface based on our database tables. It's a time saver that you can customize easily.
Summary of what youve learned!
My name is Jesse.
I was born in Michigan, but I've been living in Central Florida the past 10 years.
I've been programming since I was 12. Beginning with QBasic in school, IRC Scripting at home, and HTML in Netscape Navigator on weekends. In those days I had to "View Source" to figure out how to do anything! I wrote my first website at this age using the GeoCities free websites. I then moved to AngelFire for a while. Remember those days?
When I hit 20, I spent several years freelancing with the skills I picked up from terribly long nights of studying. Freelancing was difficult for me because being a salesman wasn't in my blood, but I enjoyed the coding parts! I primarily used Linux, PHP, MySQL, and CSS. Then jQuery a bit later.
These days I live in the corporate world. I work with a small team of people and I enjoy it. I'm doing all sort of things from building solid back-ends, REST API's, HTML5/JS games, Python Django, and sometimes a bit of monkey work.
I enjoy explaining programming not because I like to talk, but because I find it rewarding to help people along their way. In fact, I found it so rewarding that I created a Youtube channel with hundreds of videos covering programming topics.
I hope you can benefit from my years of learning, I try to present it in a simple way so you don't need wrestle with all the questions I had!