We're growing into something new. Read More
alganet

Alexandre Gaigalas  Pro


Discussion

Exception Handlers on Respect\Rest

Let's say you're crazy and designed a Hello World API that throws errors randomly. Definitely most APIs could be classified as such: $router = new Respect\Rest\Router; $router->any('/**', function() { if (rand(0,1)) { return 'Hello World'; } else { throw new RuntimeException('Gotcha!'); } }); Now you can catch those errors! Courtersy of Exception Routes: $router->exceptionRoute('RuntimeException', function($e) { return 'Caught a Gotcha!'; }); Hope you enjoy that. Also, there is something more: Error Routes ------------ These one is for catching PHP errors (Notices, Warnings, User Errors): $router->errorRoute(function($err) { return 'This errors happened: '.var_dump($err); }); Hope you like it! =D Available now on PEAR and Composer.

Discussion

I'm creating Respect\Conversion, a tool to transform and convert data

Even with frameworks and libraries, we do a lot of repetitive work on programming. This specific library tries to solve that. Let's start with something simple: $data = array( 'id' = 0, 'user' = 'alganet', 'internal_ref' => '32082bf' ); Raw Code » You may want to expose this data to a JSON API, and there are many libraries to do that. But you don't want to expose the internal reference you got, so you need to write specific logic for that. With Respect\Conversion, you do things like this: $json = json_encode( Converter::collection() ->item("internal_ref") ->delete() ->transform($data) ); Raw Code » And more complicate things like: Converter::table() ->col("internal_ref") ->delete() ->tr(v::odd()) //Using Respect/Validation ->callback(function($v) { $v['odd'] = true; return $v; })->col("name", "screen_name", "id") ->up() ->transform($otherData); Raw Code » The difference is that every conversion is an object that you can reuse and pass, even to other conversion objects. The project was made mostly this weekend and is very alpha state. Any feedback is appreciated!

Discussion

Respect bundles for Laravel

I was exploring bundles for Laravel and found this. Jerome Foray packaged some Respect tools as a Laravel bundle. There are three of them: Validation A validation tool. You can do things like v::alnum()->length(1,15)->noWhitespace()->validate($username); Full docs: documentup.com/Respect/… Config A configuration and dependency injection tool. ; db.ini [db PDO] dsn = mysql:host=localhost;dbname=mydb user = root passwd = '' setAtttribute[] = [PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION] Raw Code » Full docs: documentup.com/Respect/… Relational A database tool. Getting all comments on posts from the author that has the username "alganet" is as simple as $mapper->comment->post->author(array("username" => "alganet"))->fetchAll(); Full docs: documentup.com/Respect/… Hope this helps someone!

Discussion

Respect\Relational getting new features and better docs!

Respect\Relational is an easy tool for relational databases. We covered it before here on Forrst with great feedback! Its best features are: Near-zero configuration. Fluent interfaces like $mapper->author[7]->fetch(); Adapts itself to different database styles. We have a lot more including complex joins, conditions, ordering and everything. Our new experimental docs are at documentup.com/Respect/Relational/ Any comments, tips or issues about the docs or the project itself are very welcome. Thanks.

Discussion

Respect\Rest 0.40 is out!

Hi there! Respect\Rest is a controller library that can be used as a micro-framework and/or router for controller classes. It's designed for developing websites, apps and APIs. Usage is pretty straightforward. Micro-framework style is: $router->get('/users/*', function($userName) { //do something that returns an user }); Raw Code » Controller-class style is even simpler: $router->any('/users/*', 'MyControllerClass'); Raw Code » Many other features including content-negotiation (for serving JSON, XML, HTML and any mime type over the same content), HTTP-based authentication and much more. We've released version 0.40 a couple of days ago. This release is focused on documentation, so I'm asking you guys feedback on these docs! documentup.com/Respect/… Most features not described on this post are explained there. Thanks!

Discussion

Respect\Validation 0.4.0 is out! Next is 1.0.0-beta

Hi there! Respect\Validation is the most awesome validation engine ever created for PHP. You can do things like: v::numeric()->positive()->max(32)->validate($myInt); Raw Code » Today we're launching Respect\Validation 0.4.0. This release focus on the documentation and stability. We're looking forward feedback to release 1.0.0-beta and then 1.0.0. So, any feedback on the documentation and any bugs found are very appreciated. We hope you enjoy! Thanks

Discussion

Respect\Doc generates docs that rocks your socks off.

Why it rock your socks off: Tested code rocks! So it uses PHPUnit Test Cases to know how your code works. Doc comments, like these, are really optional. This very documentation was generated by the class itself. More Info: Author: Alexandre Gaigalas alexandre@gaigalas.net Author: Augusto Pascutti augusto@phpsp.org.br __construct($classname) Receives the class name to be documented. __toString() Returns the documentation in markdown $class = 'Respect\Doc'; $generator = new Doc($class); $markdown = (string) $generator; $doc = file_put_contents('../README.md', $markdown); //Happy Panda $this->assertStringEqualsFile('../README.md', $markdown); Raw Code »