Every ZF3-based website (including the skeleton application) is organized in the same recommended way. Of course, you can configure your application to use a different directory layout, but this may make it difficult to support your website by other people who are not familiar with such a directory structure.
Let's have a brief look at the typical directory structure (see figure 2.1):
As you can see, in the top-level directory (we will denote it
APP_DIR from now on),
there are several files:
composer.json is a JSON configuration file for Composer.
composer.lock file contains information about packages installed with Composer.
composer.phar is an executable PHP archive containing the code
of Composer dependency management tool.
Dockerfile files are auxiliary files used only if you use Docker container manager tool.
In this book, we do not cover usage of Docker.
LICENSE.md is a text file containing ZF3 license (you had a chance to read it in
Introduction to Zend Framework 3).
Do not remove or modify this file, because ZF3 license doesn't allow to do so.
phpunit.xml.dist file is a configuration for PHPUnit (unit testing framework). You use this file
when you want to create unit tests for your website.
README.md is a text file containing a brief description of the skeleton application. You typically
will replace this file contents with the information about your website: its name, what it does,
and how to install it.
TODO.md is an auxiliary file that can be safely removed.
Vagrantfile is an auxiliary file that contains configuration for Vagrant, which is a virtual development
environment manager. You can ignore this file if you don't know what is Vagrant. In this book, we do not use Vagrant.
And we also have several subdirectories:
config directory contains application-level configuration files.
data directory contains the data your application might create; it may also contain cache used to speed-up Zend Framework.
module directory contains all application modules. Currently there is a
single module called
Application is the main module of your
website. You can also put other modules here, if you wish. We will talk about
the modules a little bit later.
vendor directory's purpose is to contain third-party library files, including
Zend Framework 3 library files. This directory is typically populated by Composer.
public directory contains data publicly accessible by the web-user. As you can see, web-users
will mainly communicate with the
index.php, which is also called the entry point of your website.
Your website will have a single entry point, index.php, because this is more secure than allowing anyone to access all your PHP files.
Inside of the
public directory, you can also find hidden
.htaccess file. Its main purpose is to define
URL rewriting rules.
public directory contains several subdirectories also publicly accessible by web-users:
csssubdirectory contains all publicly accessible CSS files;
fontssubdirectory contains application-specific web-fonts;
imgsubdirectory contains publicly accessible images (.JPG, .PNG, .GIF, .ICO, etc.);
What is jQuery library?
Because the Zend Skeleton Application is stored on GitHub, inside of the directory structure,
you can find hidden
.gitignore file. This is a GIT version control
system's files. You can ignore it (or even remove them if you do not plan to store your code in a GIT repository).