While you can work with just PHP and Notepad, there is nothing like having the right environment and the right tools to get the job done right. Let's dive into some local environment options, advantages, and scopes. Let's talk about existing editors, stacks (WAMP, LAMP, MAMP, and XAMP), and what to consider when we have to purchase certain tools.
- View Offline
- For this course, this is the minimal setup that we need to follow along the movies. We will need to have php installed, we can confirm that php is installed by typing php minus v and we will need version at least 553 or after. We will also be using php's internal server and we can confirm it's working by typing php minus capital s local host 8080. With that we'll start an internal web server on 8080 port.
We can confirm that it's working by clicking on local host 8080 and this will show an empty folder because we don't have any files on the folder. However, the web server is working correctly. We'll also be using my sequel as our database, so let's stop the server with control c. Now, let's confirm that my sequel is working, in most cases, you can use my sequel directly like this. But in my case, I have to type the whole location of the files. So let's type: applications MAMP library bin my sequel, with that I can confirm that my sequel has been installed correctly.
But now we need to connect to my sequel using the user that we'll be using for the whole application. So, let's type the same command with the following parameters: minus u root which will tell the my sequel client to use the user root and to connect using a password. This will prompt for a password, which will be in this case root, but it can differ from system to system. And now we need to create the database that we'll be using for the course. Let's show databases and with that we can confirm that CI course database has not been created.
Let's create it with: create database CI underscore course and we have created our database. Let's confirm with the same command: show databases and as we can see we have the CI course database installed. Now, we need to populate it with the tables and records that we'll be using for our examples. So, let's exit that. We need to populate the database with the set of files that come with the course. In this case the file is named CI underscore course dot sql and we're going to import that to our database.
We're going to do that with the same command, but instead of just saying connect to the database, we'll be telling my sequel to connect to the database called CI course, and we'll also be telling it to import the data from the file. In this case my file is in my home folder desktop exercise files setup CI underscore course dot sql. I type my password in this case it's root and I have imported the database.
Let's go back and connect to the database again, root, and now let's use the database with: use CI course. And now let's show the tables that it has, show tables. With that we can confirm that the database has been populated with the tables. Let's do one more check with select from agents and it should have three records. This is the minimal setup that we need for the course. However, let me recommend a more fancy setup that you guys might find useful.
We could start with my sequel workbench, which is a database management tool. It's specifically designed for my sequel and can help us design our databases in a more graphic manner. Another tool that I find very useful is MAMP Pro. Now, before you complain about this suggestion, hear me out. The thing that makes MAMP Pro worth the while is this option debugger activate x debug. We'll see in a minute why it's very helpful. Another tool that comes with MAMP Pro that I would really recommend using is php my admin.
Php my admin is a my sequel tool to manage your databases. It's very simple and very pragmatic. Another tool that I would find useful for your environment is to have I term installed and fish shell installed. You can install them via brew and it can help you by suggesting the commands that you may have typed in the past so, you don't have to remember every single command that you have typed. And one last suggestion that I'm going to make is installing php storm. While configuring it initially can be painful, once it's properly configured, we can do very cool things like using x debug.
Remember what I mentioned about MAMP? Well, here's where it comes handy. Let's say we have an application, we can start debugging and we can pause the execution and also we can see the variables that have been declared, and even arrays that have been declared and the values that they contain. Debugging can be the difference between a regular programmer and an experienced programmer.
- Loading views and data from containers
- Routing with controllers
- Creating models
- Configuring the data
- Working with data, forms, sessions, and headers
- Logging and error logging
- Extending CodeIgniter to consume dependencies