Chapter: Creating an administration interface
|« Define commons processes between many actions||^ Fundamental|
− Table of content
app:initadmin command adds an administration web interface to your
application. It enables master_admin jelix module,
and can automatically configure authentication (jAuth) and
rights accesses (jAcl2).
Warning: for security reasons, and to ease the use of the framework, it is highly recommended to create a dedicated application for an administration web interface.
To create this administration interface, first, you have to configure jDb. Then you can run in your application:
php dev.php app:initadmin index
index is the name of the entry point (without the extension
dedicated to the admin interface.
If you really want to create this interface in an existing application already using index.php for other modules, you can indicate an other name, such as "admin".
The command will create the entry point if it doesn't already exist. The
configuration of the entry point will be modified in order to have a fully
functional web interface. For example, you have two new response objects into your
app/responses/ directory. So you can customize later the general interface
of the administration.
Note that before running this command, you have to configure the database access
profiles.ini.php, because it will create all needed tables for jAuth
and jAcl2. If you prefer to configure jAuth and/or jAcl2 by yourself, you can
indicate options to the command, respectively
After having created the admin interface (and configuring jAuth and jAcl2
correctly if you used
--noacl2db), you can run the
http://example.com/admin.php for example).
You will see a login form, displayed by the module jauth. By default, a user named "admin" with the password "admin" is created. After entering login and password, you will be redirected to the [[/ref-modules/master_admin|master_admin module]].
**Remember that you cannot use controllers of a module on two entry points at the same time.**. So if you already use controllers and zones of jauth in your application, for anything other than the admin interface, you'll have issues with urls and some "bizarre" behaviors, such as the login form of the admin which is submitted on the other entry point of your application, instead of the entry point of the administration. If you need to use jauth both for an admin and a public web site, you need to create two dedicated applications (they can share both modules code and databases of course).
User interface and urls ¶
Administration modules should be accessible only through the entry point
dedicated to the administration. So you must declare these modules
in the right
<entrypoint> element into the
<entrypoint name="admin"> <url pathinfo="/" module="master_admin" action="default:index" /> <url module="jauth"/> <url module="jauthdb_admin"/> <url module="jacl2db_admin"/> <!-- etc... --> </entrypoint>
Without this declaration, modules will not be accessible, because urls to them are unknown. Or it could be accessible through an other entry point, which will cause issues.
The exemple above allow to declare some basic url (
quickly, but you may want to have "cool" urls. Each provided administration
module have their own URL definition file, so you can refer to them.
For example, the administration use the auth system of jelix, jAuth. You
can then define urls for the jauth module, by including the
file provided with the jauth module.
<entrypoint name="admin"> <url pathinfo="/" module="master_admin" action="default:index" /> <url pathinfo="/login/" module="jauth" include="urls.xml" /> </entrypoint>
When you executed
app:initadmin, if you didn't deactivated authentication
with jAuthDb and/or rights management with jAcl2Db, you have then to defines urls for
the jauthdb_admin module and/or jacl2db_admin. Include their
<entrypoint name="admin"> <url pathinfo="" module="master_admin" action="default:index" /> <url pathinfo="/login/" module="jauth" include="urls.xml" /> <url pathinfo="/acl/" module="jacl2db_admin" include="urls.xml"/> <url pathinfo="/auth/" module="jauthdb_admin" include="urls.xml"/> <url pathinfo="/pref/" module="jpref_admin" include="urls.xml"/> </entrypoint>
Your administration interface is now ready.