Package Data | |
---|---|
Maintainer Username: | zzal |
Package Create Date: | 2013-05-22 |
Package Last Update: | 2013-05-22 |
Home Page: | https://packagist.org/packages/zzal/cakephp-hash |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-24 15:00:22 |
Package Statistics | |
---|---|
Total Downloads: | 2,630 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 2 |
Total Open Issues: | 0 |
Please note that this package is in beta develpment phase.
This is simply a wrapper package to help you use the awesome cakePHP’s Hash class in your non-cakePHP project (using composer). This helper class let you manipulate complex PHP arrays using Xpath-like syntax.
Install this package through Composer. To do so, edit your project's composer.json
file to require zzal/cakephp-hash
.
"require": {
"zzal/cakephp-hash": "*"
}
Then, add this inside the "autoload" section of this file:
"autoload": {
"classmap": [
…
],
"psr-0": {
"CakePHP\\Utility\\": "vendor/zzal/cakephp-hash/Hash"
}
Finally, use Composer from the Terminal:
composer install
As Laravel 4 already have a class named Hash, I suggest that you use the cakePHP Hash class with an alias, like in the following example (routes.php):
<?php
use CakePHP\Utility\Hash as ArrayXPath;
Route::get('/', function()
{
$records = array(
array(
'pages' => array(
array('id' => 1, 'title' => 'One'),
array('id' => 2, 'title' => 'Two'),
array('id' => 3, 'title' => 'Three'),
)
)
);
$result = ArrayXPath::extract($records, '{n}.pages.{n}[id=2]');
var_dump($result);
});
And the result would be:
array(1) {
[0]=>
array(2) {
["id"]=>
int(2)
["title"]=>
string(3) "Two"
}
}