Skip to main content

Aura Turns 2

·335 words·2 mins
Hari KT
Author
Hari KT
Freelancer | Founder of Tripti and Tanvish | Maintainer of Aura for PHP, created by Paul M Jones

Looking over the commits on Aura.Router, Aura.Signal etc you will notice, aura project has turned 2.

And today, I would like to introduce you, the new born baby still under active development and refactoring based on user feedback, the form library for php, Aura.Input.

The Aura.Input, doesn’t have a rendering functionality. But you can always use Aura.View or create your own helpers.

A basic filtering based on closure exists in Aura.Input. But you are not limited, you can use your own filtering components or integrate Aura.Filter.

Let us look at some code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// use composer or require '/path/to/Aura.Input/src.php';

use Aura\Input\Form;
use Aura\Input\Builder;
use Aura\Input\Filter;

$filter = new Aura\Input\Filter();

// validate
$filter->setRule('name', 'Name should be alpha only', function ($value) {
    return ctype_alpha($value);
});

$filter->setRule('email', 'Enter a valid email address', function ($value) {
    return filter_var($value, FILTER_VALIDATE_EMAIL);
});

$filter->setRule('url', 'Enter a valid url', function ($value) {
    return filter_var($value, FILTER_VALIDATE_URL);
});

$filter->setRule('message', 'Message should be more than 7 characters', function ($value) {
    if (strlen($value) > 7) {
        return true;
    }
    return false;
});

class ContactForm extends Form
{
    public function init()
    {
        $name    = $this->setField('name');
        $email   = $this->setField('email');
        $url     = $this->setField('url');
        $message = $this->setField('message', 'textarea');
    }
}

$form = new ContactForm(new Builder, $filter);

$values = [
    'name' => 'Hari K T',
    'email' => 'oh will it works!',
    'url' => 'google.com',
    'message' => 'Aweso'
];

$form->setValues($values);

$passed = $form->filter();

// 'foo' is invalid
if (! $passed) {
    // get all messages
    $actual = $form->getMessages();
    var_dump($actual);
}

Try it out, we have some more documentation for the Aura.Input. I warn the api is still not stable for Aura.Input and is not yet released a Beta.

But it is a good start!

Related

Aura.Http Request and Response

·856 words·5 mins
The Aura.Http package provide you the tool to build and send request and response. Instantiation: # The easiest way is 1 2 3 <?php $http = require 'path/to/Aura.Http/scripts/instance.php'; What it gives you is an object of Aura\Http\Manager. If you want to create manually you can look into the instance.php Building your Response # Probably you may not have bothered too much on building the http response either the framework does it for you, or until you need to send the correct response.

Aura Framework Releases Beta 4

·41 words·1 min
Aura.Framework released Beta4. In this release Aura.Framework has extracted the Hello Word package and renamed it as Aura.Demo. You can get the system as a whole from http://auraphp.github.com/system/downloads/ Read about the release from blog post and join discussion at auraphp group

Our Awesome PHP People

·1175 words·6 mins
Recently github introduces contributions chart. So I peeped into some of the people of our php community. It seems @fabpot is the one who contributes almost every day. Just 21 days without any contribution. {% img center /assets/images/github/fabpot.png 687 299 ‘Contributions by fabpot’ ‘Contributions by fabpot’ %} {% img center /assets/images/github/weierophinney.png 687 299 ‘Contributions by weierophinney’ ‘Contributions by weierophinney’ %} {% img center /assets/images/github/pmjones.png 687 299 ‘Contributions by pmjones’ ‘Contributions by pmjones’ %} {% img center /assets/images/github/willdurand.png 687 299 ‘Contributions by willdurand’ ‘Contributions by willdurand’ %} {% img center /assets/images/github/Seldaek.png 687 299 ‘Contributions by Seldaek’ ‘Contributions by Seldaek’ %} {% img center /assets/images/github/markstory.png 687 299 ‘Contributions by markstory’ ‘Contributions by markstory’ %} {% img center /assets/images/github/taylorotwell.png 687 299 ‘Contributions by taylorotwell’ ‘Contributions by taylorotwell’ %} {% img center /assets/images/github/WanWizard.png 687 299 ‘Contributions by WanWizard’ ‘Contributions by WanWizard’ %} {% img center /assets/images/github/drak.png 687 299 ‘Contributions by drak’ ‘Contributions by drak’ %} {% img center /assets/images/github/nikic.png 687 299 ‘Contributions by nikic’ ‘Contributions by nikic’ %} {% img center /assets/images/github/avalanche123.png 687 299 ‘Contributions by avalanche123’ ‘Contributions by avalanche123’ %} {% img center /assets/images/github/shama.png 687 299 ‘Contributions by shama’ ‘Contributions by shama’ %} {% img center /assets/images/github/vrana.png 687 299 ‘Contributions by vrana’ ‘Contributions by vrana’ %} {% img center /assets/images/github/philsturgeon.png 687 299 ‘Contributions by philsturgeon’ ‘Contributions by philsturgeon’ %} {% img center /assets/images/github/DASPRiD.png 687 299 ‘Contributions by DASPRiD’ ‘Contributions by DASPRiD’ %} {% img center /assets/images/github/mvriel.png 687 299 ‘Contributions by mvriel’ ‘Contributions by mvriel’ %} {% img center /assets/images/github/c9s.png 687 299 ‘Contributions by c9s’ ‘Contributions by c9s’ %} {% img center /assets/images/github/weaverryan.png 687 299 ‘Contributions by weaverryan’ ‘Contributions by weaverryan’ %} {% img center /assets/images/github/bschussek.png 687 299 ‘Contributions by bschussek’ ‘Contributions by bschussek’ %} {% img center /assets/images/github/vicb.png 687 299 ‘Contributions by vicb’ ‘Contributions by nateabele’ %} {% img center /assets/images/github/garak.png 687 299 ‘Contributions by garak’ ‘Contributions by garak’ %} {% img center /assets/images/github/beberlei.png 687 299 ‘Contributions by beberlei’ ‘Contributions by beberlei’ %} {% img center /assets/images/github/codeguy.png 687 299 ‘Contributions by codeguy’ ‘Contributions by codeguy’ %} {% img center /assets/images/github/lsmith77.png 687 299 ‘Contributions by lsmith77’ ‘Contributions by lsmith77’ %} {% img center /assets/images/github/stof.png 687 299 ‘Contributions by stof’ ‘Contributions by stof’ %} {% img center /assets/images/github/EavnDotPro.png 687 299 ‘Contributions by EavnDotPro’ ‘Contributions by EavnDotPro’ %} {% img center /assets/images/github/nateabele.png 687 299 ‘Contributions by nateabele’ ‘Contributions by nateabele’ %} {% img center /assets/images/github/kriswallsmith.png 687 299 ‘Contributions by kriswallsmith’ ‘Contributions by kriswallsmith’ %} {% img center /assets/images/github/nrk.png 687 299 ‘Contributions by nrk’ ‘Contributions by nrk’ %} {% img center /assets/images/github/naderman.png 687 299 ‘Contributions by naderman’ ‘Contributions by naderman’ %} {% img center /assets/images/github/gwoo.png 687 299 ‘Contributions by gwoo’ ‘Contributions by gwoo’ %} {% img center /assets/images/github/jwage.png 687 299 ‘Contributions by jwage’ ‘Contributions by jwage’ %} {% img center /assets/images/github/chartjes.png 687 299 ‘Contributions by chartjes’ ‘Contributions by chartjes’ %} {% img center /assets/images/github/Tocacar.png 687 299 ‘Contributions by Tocacar’ ‘Contributions by Tocacar’ %} {% img center /assets/images/github/FrenkyNet.png 687 299 ‘Contributions by FrenkyNet’ ‘Contributions by FrenkyNet’ %} {% img center /assets/images/github/till.png 687 299 ‘Contributions by till’ ‘Contributions by till’ %} {% img center /assets/images/github/Ocramius.png 687 299 ‘Contributions by Ocramius’ ‘Contributions by Ocramius’ %} {% img center /assets/images/github/odino.png 687 299 ‘Contributions by odino’ ‘Contributions by odino’ %} {% img center /assets/images/github/josegonzalez.png 687 299 ‘Contributions by josegonzalez’ ‘Contributions by josegonzalez’ %} {% img center /assets/images/github/dereuromark.png 687 299 ‘Contributions by dereuromark’ ‘Contributions by dereuromark’ %} {% img center /assets/images/github/HosipLan.png 687 299 ‘Contributions by HosipLan’ ‘Contributions by HosipLan’ %} {% img center /assets/images/github/alganet.png 687 299 ‘Contributions by alganet’ ‘Contributions by alganet’ %} {% img center /assets/images/github/ezimuel.png 687 299 ‘Contributions by ezimuel’ ‘Contributions by ezimuel’ %} {% img center /assets/images/github/auroraeosrose.png 687 299 ‘Contributions by auroraeosrose’ ‘Contributions by auroraeosrose’ %} {% img center /assets/images/github/enygma.png 687 299 ‘Contributions by enygma’ ‘Contributions by enygma’ %} {% img center /assets/images/github/ralphschindler.png 687 299 ‘Contributions by ralphschindler’ ‘Contributions by ralphschindler’ %} {% img center /assets/images/github/AD7six.png 687 299 ‘Contributions by AD7six’ ‘Contributions by AD7six’ %} {% img center /assets/images/github/ADmad.png 687 299 ‘Contributions by ADmad’ ‘Contributions by ADmad’ %} {% img center /assets/images/github/augustohp.png 687 299 ‘Contributions by augustohp’ ‘Contributions by augustohp’ %} {% img center /assets/images/github/BlaineSch.png 687 299 ‘Contributions by BlaineSch’ ‘Contributions by BlaineSch’ %} {% img center /assets/images/github/alexbilbie.png 687 299 ‘Contributions by alexbilbie’ ‘Contributions by alexbilbie’ %} {% img center /assets/images/github/narfbg.png 687 299 ‘Contributions by narfbg’ ‘Contributions by narfbg’ %} {% img center /assets/images/github/dg.png 687 299 ‘Contributions by dg’ ‘Contributions by dg’ %} {% img center /assets/images/github/schmittjoh.png 687 299 ‘Contributions by schmittjoh’ ‘Contributions by schmittjoh’ %} {% img center /assets/images/github/jschreuder.png 687 299 ‘Contributions by jschreuder’ ‘Contributions by jschreuder’ %} {% img center /assets/images/github/Geczy.png 687 299 ‘Contributions by Geczy’ ‘Contributions by Geczy’ %} {% img center /assets/images/github/dzuelke.png 687 299 ‘Contributions by dzuelke’ ‘Contributions by dzuelke’ %} {% img center /assets/images/github/evert.png 687 299 ‘Contributions by evert’ ‘Contributions by evert’ %} {% img center /assets/images/github/akrabat.png 687 299 ‘Contributions by akrabat’ ‘Contributions by akrabat’ %} {% img center /assets/images/github/seejohnrun.png 687 299 ‘Contributions by seejohnrun’ ‘Contributions by seejohnrun’ %} {% img center /assets/images/github/guilhermeblanco.png 687 299 ‘Contributions by guilhermeblanco’ ‘Contributions by guilhermeblanco’ %} {% img center /assets/images/github/Maks3w.png 687 299 ‘Contributions by Maks3w’ ‘Contributions by Maks3w’ %} {% img center /assets/images/github/kore.png 687 299 ‘Contributions by kore’ ‘Contributions by kore’ %} {% img center /assets/images/github/dragoonis.png 687 299 ‘Contributions by dragoonis’ ‘Contributions by dragoonis’ %} {% img center /assets/images/github/daschl.png 687 299 ‘Contributions by daschl’ ‘Contributions by daschl’ %} {% img center /assets/images/github/wilmoore.png 687 299 ‘Contributions by wilmoore’ ‘Contributions by wilmoore’ %} {% img center /assets/images/github/TheFrozenFire.png 687 299 ‘Contributions by TheFrozenFire’ ‘Contributions by TheFrozenFire’ %} {% img center /assets/images/github/nickl-.png 687 299 ‘Contributions by nickl-’ ‘Contributions by nickl-’ %} {% img center /assets/images/github/lorenzo.png 687 299 ‘Contributions by lorenzo’ ‘Contributions by lorenzo’ %} {% img center /assets/images/github/rchavik.png 687 299 ‘Contributions by rchavik’ ‘Contributions by rchavik’ %} {% img center /assets/images/github/davidpersson.png 687 299 ‘Contributions by davidpersson’ ‘Contributions by davidpersson’ %} {% img center /assets/images/github/henriquemoody.png 687 299 ‘Contributions by henriquemoody’ ‘Contributions by henriquemoody’ %} {% img center /assets/images/github/Freeaqingme.png 687 299 ‘Contributions by Freeaqingme’ ‘Contributions by Freeaqingme’ %} {% img center /assets/images/github/dbu.png 687 299 ‘Contributions by dbu’ ‘Contributions by dbu’ %} {% img center /assets/images/github/dshafik.png 687 299 ‘Contributions by dshafik’ ‘Contributions by dshafik’ %} {% img center /assets/images/github/Vrtak-CZ.png 687 299 ‘Contributions by Vrtak-CZ’ ‘Contributions by Vrtak-CZ’ %} {% img center /assets/images/github/padraic.png 687 299 ‘Contributions by padraic’ ‘Contributions by padraic’ %} {% img center /assets/images/github/saltybeagle.png 687 299 ‘Contributions by saltybeagle’ ‘Contributions by saltybeagle’ %} {% img center /assets/images/github/Hounddog.png 687 299 ‘Contributions by Hounddog’ ‘Contributions by Hounddog’ %} {% img center /assets/images/github/ceeram.png 687 299 ‘Contributions by ceeram’ ‘Contributions by ceeram’ %} {% img center /assets/images/github/jmikola.png 687 299 ‘Contributions by jmikola’ ‘Contributions by jmikola’ %} {% img center /assets/images/github/cweiske.png 687 299 ‘Contributions by cweiske’ ‘Contributions by cweiske’ %} {% img center /assets/images/github/rdohms.png 687 299 ‘Contributions by rdohms’ ‘Contributions by rdohms’ %}