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.
docker-compose.yml
and 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:
The config
directory contains application-level configuration files.
The data
directory contains the data your application might create; it may also contain cache used to speed-up Zend Framework.
The module
directory contains all application modules. Currently there is a
single module called Application
. The 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.
The vendor
directory's purpose is to contain third-party library files, including
Zend Framework 3 library files. This directory is typically populated by Composer.
The 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.
The public
directory contains several subdirectories also publicly accessible by web-users:
css
subdirectory contains all publicly accessible CSS files;fonts
subdirectory contains application-specific web-fonts;img
subdirectory contains publicly accessible images (.JPG, .PNG, .GIF, .ICO, etc.);js
subdirectory stores publicly accessible JavaScript files used by your web-pages.
Typically, files of jQuery library are placed here, but you can put your own JavaScript files here, too. What is jQuery library?
jQuery is a JavaScript library which was created to simplify the client-side scripting of HTML pages. jQuery's selector mechanism allows to easily attach event handlers to certain HTML elements, making it really simple to make your HTML pages interactive.
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).