Zend Skeleton Application contains this composer.json in its root project folder. You see there that it requires certain modules, including one for installation. You also see autoload
. Now, each of the to-be-loaded/required modules may do the same, creating a structure of additional composer.json files and requirements. In linked file, you see that zendframework/zend-mvc
is required ("zendframework/zend-mvc": "^3.0.1",
)
Have a look then at zendframework/zend-form's composer.json file. You'll see there additions require
keys and versions as well as an additional autoload
key. All of those (and even more) get mashed together to create a single installable package. That package is your complete installation and, after installation, everything in your vendor/
map in your project (next to the root composer.json
file of your project).
Below I've got a slightly modified (removed some stuff not relevant to question and highlighted others) screenshot of the composer.json for a current project.
On the left you see the folder structure. At the bottom you see the files composer.json
and composer.lock
.
The .json (middle screen) contains the root requirements for the project. As each package may have it's own requirements, the composer.lock
is generated during installation (file on the right). That file contains every installed version. (Created using composer install
command).
As you can see in the .lock
file, somewhere there's a requirement for the package 51systems/doctrine-encrypt
. As you can also read there, that package has it's own requirements and namespace to load.

Now, the Composer installation process also creates your autoloading.
Zend Framework kicks off autoloading in the application itself, but it uses the included files from the vendor/autoload.php
file. Below is a bit from the public/index.php
, relevant to autoload. For the full thing, install the framework or look on Github.
// Composer autoloading
include __DIR__ . '/../vendor/autoload.php';
// ... other stuff
// Run the application!
Application::init($appConfig)->run();
Ok, that shows us we're including vendor/autoload.php
. Let's see:
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7befb6b36ba61da7e01a592b255158ab::getLoader();
Hmmm... yea, that's the entire file. Not a lot. However, we can follow this as well.
In the vendor
folder you'll find a folder named composer
. Here you'll several files starting with autoload_
, these make sure that every file registered via those composer.json
files (config PSR-0
or PSR-4
in key autoload
) get loaded.
So, including the vendor/autoload.php
really is enough. Click through them and see.
Next up you use namespaces to use other classes. You asked about that, but seeing the scope of this question, you should make that a separate question. Also, read up on namespaces with the link I send you in the comments.
Discussion is getting out of hand below, so in steps, do the following:
- Make sure you have a host setup (On: Ubuntu (Apache), Windows 10 (Apache), Mac (Apache), Ubuntu (nginx), Windows 10 (nginx), Mac (nginx)) (have it be an empty folder for now, call it "skeleton", hostname "skeleton.loc")
- Download the Zend Skeleton Application (direct .zip link)
- Unpack in new folder from step 1 ("skeleton")
- Open the host folder "skeleton" in a Terminal session
- Run
composer install
(from "skeleton" Terminal session) (you want to "inject into module.config.php
during installation for all options (not being picky this time), that's option 1
(every time))
- Wait for installation to run
- Visit "skeleton.loc" (maybe canonical: http://skeleton.loc/) in your browser, you should see image below (but for ZF3 ;), ripped it from internet)
