I am not a student - a guide for external readers

This book is available online and is suitable for everybody, who is interested in web-site development with minimal prior knowledge in this field. You should have basic understanding of programming, willpower and some spare time to read this book and complete the assignments.

If you are not a student of Mendel University you will need some means to execute your programs:

  • web server with PHP 5.6 or higher
  • database server (PostgreSQL or MySQL/MariaDB)
  • web browser
  • text editor or IDE

Most of tools I am going to recommend to you here are platform independent and free of charge.

Web server with PHP and a database

This is the most complicated part for external readers – I cannot provide you an execution environment for PHP and you cannot execute your scripts without one. You have to obtain PHP interpreter and web server somehow.

Easiest way for a beginner is to register a free web hosting service. You can search online for phrase PHP free hosting. These services are usually not very reliable but it is OK for start. These free hostings usually provide a third level domain name for free (something like yourname.server.com). Sometimes they will place ads into your website which can scramble your scripts a bit. You will get access codes to shared hosting server – usually an FTP account. You can use free FTP client like FileZilla to transfer your PHP script to a server. They will also provide you a limited database account (one database, limited amount of space), usually MySQL with phpMyAdmin as control interface.

Better way is to rent a PHP hosting. These services are cheap – not much more than a few dollars per month. But you will have to purchase also a second level domain (yourname.com). Prices of domains are different according to the top level domain (a domain with TLD .info is cheaper than .com). Domain price is also quite low – few dollars per a year. This environment is much more stable and obviously ad-free. You can also get support from your service provider.

Read more about deploying the application in walkthrough.

Installing your own server on your PC

You can use PHP development server. This means that you install PHP interpreter on your system, call php -S localhost:8000 command in a terminal which opens specified port (8000) and you can run your application directly from this small development server – http://localhost:8000. You will still need to install database server to work with a database.

Apache based stack and a database (advanced)

You can try to install WAMP Server package or XAMPP on Windows. PHP is configured as Apache module in this case and you do not have to execute it separately.

These packages contain MySQL database instead of PostgreSQL which is used in my examples. Most SQL queries is same in both systems and I tried to provide alternatives and comments on MySQL in cases of difference. Another database system which you can encounter is MariaDB. This an open source variant of MySQL.

To install all these programs and make it work together at your own is definitely a lot of work and effort. If you are absolutely lost and do not know where to start, try to register a free PHP hosting. You will get better understanding of these programs and their roles in web application development after you read this book.

On Linux based systems use your package manager to download Apache, PHP and PostgreSQL. Your website should be usually placed into /var/www/html directory. Installation of SQL server is a bit trickier because it involves setting of user accounts – consult manual.

After you install your own Apache+PHP+DB or PHP-dev-sever+DB stack, you should be able to execute your PHP script from any internet browser by typing an address of your own computer: http://localhost. Default HTTP port is 80, if you use another, type e.g. http://localhost:8080.

To create a database or modify tables use a tool called Adminer. It is a single PHP script placed anywhere in your web directory – you can access it by typing e.g. http://localhost/adminer.php. I also use it in this book.

Another option is to use embedded database system like SQLite. PHP has a plugin to work with this type of database (just install it and/or enable it in PHP config file php.ini – found in PHP’s home directory). You can then use PDO interface to communicate with it in your scripts and Adminer supports it too (you just type relative path to datafile instead of hostname and port). This kind of database can be used with pure PHP development server.

Web browser

Any modern web-browser is suitable. I recommend Mozilla Firefox or Google Chrome. Important feature which your browser should have is some kind of developer tools with network console and DOM inspector. This feature is usually under F12 key or in application’s menu.

Opening developer tools

Developer tools - network console

Text editor or IDE

You should at least install a text editor which is suitable for developers - important features are UTF8 support and syntax highlighting for PHP/HTML/CSS scripts. Good choices are Notepad++ for Windows or Geany for Linux. Another choice can be Atom editor which is multi-platform.

Geany

I recommend to install full IDE (Integrated Development Environment) – a free IDE called NetBeans can be downloaded – select PHP stack on download page. Eclipse IDE is also free but not much popular for PHP development nowadays. There are also commercial IDEs like PHP storm. In NetBeans you also get support for Latte templates.

If you had never worked with an IDE, do not bother yourself with this for now and just download a good text editor. You can always switch to an IDE later.

NetBeans