Each code sample in this book is provided in a GitHub repository at https://github.com/spbooks/phpmysql6
. Where a set of code for an example is available in the archive, it is either captioned with its name over the code sample itself (for example PHP-Loops), or I’ll let you know the name of the set of code in the text. You can find the complete sample code on the GitHub repository. In Git’s terminology, each set of code is known as a branch.
There are two ways to use the sample code.
If you just want to view the code for a specific file in a single example, you can do it easily on GitHub. Choose the example by it’s name using the Branch
dropdown on the main GitHub page. You will then see a list of files and directories for the selected example (In Git’s terms, this is a Branch) and can click on each file to view the code.
Alternatively, if you would like to easily run the sample code without having to copy and paste files in and out of the web server’s Project
directory you can easily do this. I’ve provided a tool that allows you to quickly and easily view any of the code samples.
To use the code samples, follow these steps:
Project
directory is empty.Using the git bash
tool you use to boot the virtual machine, make sure you have navigated to the directory you normally run vagrant up
from then run the following command:
git clone https://github.com/spbooks/phpmysql6 Project
Visit http://192.168.10.10/samples/
, you’ll see a list of all the available samples.
Click on the name of the sample you want to view and the files will be created in the Project
directory and view the files on the URL http://192.168.10.10/
.
Project
Directory Will Be RemovedOnce on a specific sample, the Project
directory will contain only code for the sample you are viewing. If you had been working on any files they will be hidden. They have not been deleted!
Each time you switch between samples, any changes you have made will be backed up in their own branch based on the branch you made changes to. By default, you will be on the master branch. When you switch to one of the samples, all files you have created in the Project
folder will be saved into a branch called master followed by the date at time the snapshot was taken. For example: Master_2017-10-01-17.16.52. You can get your code back by switching to this new branch from the list at http://192.168.10.10/samples/
.
All the sample code uses the database ijdb_sample
. This database will be deleted and recreated each time you switch between samples, any changes you make to the ijdb_sample
database will be lost when you switch between samples. If you are following the book, you should make all your changes to the ijdb
database.
18.222.148.124