A free and open-source book on ZF3 for beginners


2.2. Typical Directory Structure

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):

Figure 2.1. Typical Directory Structure Figure 2.1. Typical Directory Structure

As you can see, in the top-level directory (we will denote it APP_DIR from now on), there are several files:

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:

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).


Top