Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/softmonkeyjapan/cakephp-objectify-behavior
ObjectifyBehavior for CakePHP 2.x. Transform regular array returned by the ORM into object
https://github.com/softmonkeyjapan/cakephp-objectify-behavior
Last synced: 5 days ago
JSON representation
ObjectifyBehavior for CakePHP 2.x. Transform regular array returned by the ORM into object
- Host: GitHub
- URL: https://github.com/softmonkeyjapan/cakephp-objectify-behavior
- Owner: softmonkeyjapan
- Created: 2013-03-27T01:11:48.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-10T22:29:46.000Z (about 10 years ago)
- Last Synced: 2023-05-20T15:00:39.358Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 134 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Objectify Behavior (Plugin CakePHP)
ObjectifyBehavior aims to convert the usual array that CakePHP return ( e.g, find() ) into an object.
## Requirements
* CakePHP 2.x
* PHP5## Installation
_[Manual]_
* Download this: [https://github.com/SoftMonkeyJapan/ObjectifyBehavior/archive/master.zip](https://github.com/SoftMonkeyJapan/ObjectifyBehavior/archive/master.zip)
* Unzip that download.
* Go into the unzip folder
* Copy the file `ObjectifyBehavior.php` to `Models/Behaviors`_[GIT Clone]_
In your `Models/Behaviors` directory type:
```bash
git clone -b master git://github.com/SoftMonkeyJapan/ObjectifyBehavior.git
cp ObjectifyBehavior/ObjectifyBehavior.php ./ObjectifyBehavior.php
```## Usage
### Initialization
Go into your model :
```php
Post->objectify(true); // Enable
$this->Post->objectify(false); // Disable
}
}
```And that's all. You're now good to go. You can simply access the attributes as an object :
```php
Post->objectify(true);// Find first
$post = $this->Post->find('first');
echo $post->name;// Example with a find all
$posts = $this->Post->find('all');
foreach ($posts as $post)
{
echo $post->name;
echo $post->content;
}
}
}
```## License
You are allowed to use it for whatever you want and whenever you want.