[RELEASE] Alexya Framework - Lightweigh PHP Framework

07/07/2015 17:38 manulaiko3.0#1
Hi!

I've just finished a framework I was working on and decided to release it.


I'll put the github link over here: [Only registered and activated users can see links. Click Here To Register...] and you'll check it, once I get back home I'll post a tutorial.


See you!
07/09/2015 02:43 manulaiko3.0#2
I've made a quick tutorial to help you getting started, when I have more free time I'll write the whole documentation.

Here's the tutorial: [Only registered and activated users can see links. Click Here To Register...]


See you!
07/13/2015 22:38 manulaiko3.0#3
New release, version v0.2.0 (Blazed), download from github: [Only registered and activated users can see links. Click Here To Register...]

Changelog:
  • Added support for Smarty variables
  • Added support for default route


How to use Smarty variables
There are 2 kind of Smarty variables in Alexya:
  • Global Variables
  • Local Variables

Global Variables
A global variable is a Smarty variable that is accessible in all views, for example the default variable URL is accessible in ALL views of the project, you can use like this:

HTML Code:
<!-- File Test.tpl -->
<a href="{$URL}">Home page</a>
HTML Code:
<!-- File Test2.tpl -->
<a href="{$URL}Login">Login</a>
To declare a global variable you must add it to the array "SmartyVariables", the key is the name that will be used in Smarty and the value is the value (logically). To add a global variable you must do this:

PHP Code:
//File index.php
$SmartyVariables["test"] = "Testing global variable";

//Usage example:
/*
<a href="{$URL}">{$test}</a>
*/ 
Adding global variables inside a function or a class is kinda similar:
PHP Code:
class Test
{
    public function 
addVariable($name$value)
    {
        
$GLOBALS["SmartyVariables"][$name] = $value;
    }
}

function 
anotherWayToAddVariable($name$value)
{
    global 
$SmartyVariables;

    
$SmartyVariables[$name] = $value;

Once you've added the variables to the SmartyVariables they can be used in ALL views.

Local variables
A local variable is a variable that can be accessed just in one view.
To add a local variable you must add it to the array SmartyVariables inside the Model class:

PHP Code:
class Model_Test extends Core_Model
{
    public function 
__construct()
    {
        
$this->SmartyVariables["test"] = "Test local variable";
    }

And that's it, there's no need to make the $SmartyVariables array since is already declared in the base class Core_Model.

Default route
Sometimes you'll need a default action to execute if the Router didn't match any route, if so, you can use the "default" route:

PHP Code:
$Router->add("default", function() {
    die(
"No routes matched the request, please go back and try again!");
}); 
And that's it, there's nothing else to do, the "default" will be executed only if there's no matching route.
If there's no default route and the route didn't match any route added, Alexya will throw an exception saying so.

See you!