Working with application
Managing aliases for URL and CLI arguments
As is common now, most frameworks provide ways to make a URL shorter, more readable and more meaninful. This usually helps optimizing the ranking of the URL with search engines. In our case, using aliasing makes it possible to create even shorter calls both in Web mode and CLI mode.
If, for example, we have an addon (controller) named "home" and a function named "welcome" which we want to call with the parameter "name=David", we should normally call it with:
On the other hand, if we now insert the following alias definition in the aliases configuration file:
[hello] addon=home action=welcome params=name/David template=hello_template
we can now make the same call just like this:
In CLI mode, using aliasing will save you quite some typing since the regular command:
/usr/bin/php index.php --addon home --action welcome --name David
would be shortened into:
/usr/bin/php index.php --hello
Obviously, in CLI mode the template is meaningless and is simply ignored.
If the parameter in alias definition exists as 'name/David', and the request contains same name of parameter, then received new parameters with the same name will be ignored. In other words, parameters defined in alias are main and cannot be overriden.
HTTP request: http://example.com/hello/name/Simon/surname/Simonyan CLI command: /usr/bin/php index.php --hello --name Simon --surname Simonyan
Result of example:
name David surname Simonyan
Aliasing configuration file path: /application/config/aliases.ini