Skip to content

Commit

Permalink
doc controller methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheron committed Oct 18, 2017
1 parent 51b2bdd commit 7a95ae3
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions docs/controller/controllers.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Ubiquity Controllers
====================
| A controller is a PHP class inheriting from ``micro\\controllers\\Controller``, providing an entry point in the application.
| Controllers and their methods define accessible URLs.
|A controller is a PHP class inheriting from ``micro\\controllers\\Controller``, providing an entry point in the application.
|Controllers and their methods define accessible URLs.
Controller creation
-------------------
The easiest way to create a controller is to do it from the devtools.

| From the command prompt, go to the project folder.
| To create the Products controller, use the command:
|From the command prompt, go to the project folder.
|To create the Products controller, use the command:
::
Micro controller Products
The Products.php controller is created in the ``app/controllers`` folder of the project.
::
<?php
namespace controllers;
/**
* Controller Products
Expand All @@ -31,6 +30,7 @@ It is now possible to access URLs (the ``index`` method is solicited by default)
example.com/Products/index

.. note:: A controller can be created manually. In this case, he must respect the following rules:

* The class must be in the ``app/controllers`` folder
* The name of the class must match the name of the php file
* It must inherit from ``ControllerBase`` and be defined in the namespace ``controllers``
Expand All @@ -40,6 +40,23 @@ Methods
-------
public
^^^^^^
The second segment of the URI determines which public method in the controller gets called.\n
The “index” method is always loaded by default if the second segment of the URI is empty.
::
class First extends ControllerBase{
public function hello(){
echo "Hello world!";
}
}

The ``hello`` method of the ``First`` controller makes the following URL available:
::
example.com/First/hello

method arguments
^^^^^^^^^^^^^^^^

private
^^^^^^^
Expand Down

0 comments on commit 7a95ae3

Please sign in to comment.