Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Próxima revisión
Revisión previa
routing [2016/01/05 04:16]
luchothoma creado
routing [2016/12/30 18:42] (actual)
Línea 5: Línea 5:
  
 **Working With Routes** **Working With Routes**
-Route configuration for your application can be changed by editing the application/​configuration/​routes.php file.</br>If you open this up it should look something like this:+Route configuration for your application can be changed by editing the application/​configuration/​routes.php file. 
 +If you open this up it should look something like this:
 <code php | routes.php>​ <code php | routes.php>​
 namespace Salem; namespace Salem;
-// Default Route 
 Route::​add(  ​ Route::​add(  ​
 array( ​ array( ​
-'/'​ => '​mycontroller/functionHandler'​ , //this refers to your __domain.com/​__ that will be manage the petition by the application/​controllers/​mycontroller.php file and launch the functionHandeler() fun respectively. +'/'​ => '​mycontroller.functionHandler'​ , //this refers to your __domain.com/​__ that will be manage the petition by the application/​controllers/​mycontroller.php file and launch the functionHandeler() fun respectively. 
 +'​mypage','​mycontroller.func',​ //in this case the function is called with a static argument, cause never change. 
 +'​query/:​alpha/:​int'​ => '​subfolder/​othercontroller.getQuery'​ //dynamic route , multi-arguments and access to sub folder inside controller one
 )//End of array )//End of array
 ); );
Línea 18: Línea 19:
 Let's say you had a page located at mycontroller/​func/​argument. Add that onto your domain name and you have a pretty long URL on your hands, so you want to be able to access that exact same page via the very small URL mypage. All you have to do is add a item into the array inside the routes.php file as above. Let's say you had a page located at mycontroller/​func/​argument. Add that onto your domain name and you have a pretty long URL on your hands, so you want to be able to access that exact same page via the very small URL mypage. All you have to do is add a item into the array inside the routes.php file as above.
  
-route::​set('​mypage','​mycontroller/​func/​argument'​);​ 
 Now if you visit index.php/​mypage you should see the exact same thing as if you visited index.php/​mycontroller/​func/​argument. Now if you visit index.php/​mypage you should see the exact same thing as if you visited index.php/​mycontroller/​func/​argument.
  
-Dynamic Routes +**Dynamic Routes** 
-Dingo also allows you to use regular expressions in your routes.+It also allows you to use regular expressions in your routes. Salem take this easy to you,  only need to know the type of "​arguments"​ needed. 
 + 
 +  * //int// (0,​-1,​2,​...) 
 +  * //numeric// (0.45,1, 3.33) 
 +  * //alpha// (Luciano, Thoma, LucianoThoma) 
 +  * //​alpha-numeric//​ (Category2, Version5.5) 
 +  * //words// (Adds - and 'blank space' from alpha-numeric) 
 +  * //​extension//​ (especific.pdf,​ some.doc) 
 +  *//any// (talk by it own) 
 + 
 + 
 +The above third route would cause you to see domain.com/​query/​test/​123 equal as if you visited domain.com/​index.php/​one/​test/​123456.
  
-route::​set('​one/​([a-zA-Z]+)/([0-9]+)','​query/​$1/​$2'​);​ +---- 
-The above would cause you to see index.php/​query/​test/​123456 if you visited index.php/​one/​test/​123456.+[[documentation|Go back to Documentation]]