Composer has become the de facto standard for installing libraries in the php world. Aura framework does the same.
Replace {$PROJECT_PATH} with real path
It will create the {$PROJECT_PATH}
directory and install the dependencies in vendor folder.
The directory structure looks something similar to this. The list is not complete for we have removed some of the files and directories.
The web/index.php
is where you need to point your virtual host. Check out setting up your virtual host for more information.
For the current time, let us make use of the built-in PHP server.
If you point your web browser to http://localhost:8000
you can see the message Hello World!
.
Great! Everything is working fine.
Open the file config/Common.php
. Look into the modifyWebRouter()
and
modifyWebDispatcher()
methods.
The modifyWebRouter()
gets the shared router service and adds a route named hello
which points to /
. So any request to http://localhost:8000
is satisfied by route named hello
.
Now we have the route, the router don’t know what to do when a request come. The dispatcher is what helps to dispatch things.
We get the shared dispatcher service, set the same name as in the controller of route in setObject
, and use a Closure or Callable.
In this example we are using a Closure, which get the di container and use it as a service, get the shared web response and set the content.
Don’t worry too much about dependency injection and dependency injection container. We will be talking more details in the coming chapter.