Download .zip |
Info | Example | View files (72) | Download .zip | Reputation | Support forum | Blog (1) | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-08-22 (16 hours ago) | Not yet rated by the users | Total: 248 This week: 5 | All time: 7,541 This week: 127 |
Version | License | PHP version | Categories | |||
caribu 1.6 | BSD License | 7 | PHP 5, Databases, Design Patterns |
Description | Author | |
This package can map objects to databases records using annotations. Recommendations Map database records to objects Innovation Award |
An annotation-based PHP Object Relational Mapper
This project aims to be an object relational mapper easy to use. The main target is to support developers writing only simple attribute containing classes and store it as entities into a database.
It has support for annotations so it is very flexible.
Here is a very basic example about the usage (for sqlite):
CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT);
/SuperDuperEntity.php/
/
* @table super_duper_content
*/
class SuperDuperEntity extends AbstractModel
{
/
* @column id
*/
private $sid;
private $content;
public function setSid($sid)
{
$this->sid = $sid;
}
public function getSid()
{
return $this->sid;
}
public function setContent($content)
{
$this->content = $content;
}
public function getContent()
{
return $this->content;
}
}
/write-data-example.php/
use \Nkey\Caribu\Orm\Orm;
/First configure the ORM/
Orm::configure(array(
'type' => 'sqlite',
'file' => ':memory:'
));
// Create sqlite database table for memory storage
// Orm::getInstance()->getConnection()->exec("CREATE TABLE super_duper_content (id INTEGER PRIMARY KEY, content TEXT)");
/Now create a new entity and persist it to database/
$entity = new SuperDuperEntity();
$entity->setContent("Mega important content");
$entity->persist();
/read-data-example.php/
/First read the entity from database/
$entity = SuperDuperEntity::find(array('content' => "Mega important content"));
/Display the content/
echo $entity->getContent();
No need to write infrastructure and boilerblate code by yourself. Let the Orm do the hard work for you.
Caribu provides a convention-over-configuration behaviour by supporting annotations.
See the Wiki for more information about the capabilities and usage.
Files |
File | Role | Description | ||
---|---|---|---|---|
contrib (2 files) | ||||
src (3 directories) | ||||
tests (4 files, 5 directories) | ||||
.gitignore | Data | Ignore list | ||
.travis.yml | Data | Travis ci configuration | ||
build.xml | Data | Build script | ||
composer.json | Data | Composer dependencies | ||
LICENSE | Lic. | License | ||
phpcs.xml | Data | Code style configuration | ||
phpdox.xml | Data | phpdox configuration | ||
phpmd.xml | Data | Mess detection configuration | ||
phpunit.xml | Data | PHPUnit configuration | ||
README.md | Doc. | Readme |
Files | / | contrib |
File | Role | Description |
---|---|---|
phpcs.xsd | Data | Code style schema |
phpunit.xsd | Data | PHPUnit schema |
Files | / | src | / | Orm |
File | Role | Description |
---|---|---|
Orm.php | Class | Caribu ORM main class |
OrmAnnotation.php | Class | Caribu ORM annotation provider |
OrmClassUtil.php | Class | Class analysis functionality |
OrmConnection.php | Class | Connection related functionality |
OrmDataType.php | Class | Data type enumeration |
OrmDataTypeConverter.php | Class | Data type conversion provider |
OrmEntityAnalyzer.php | Class | Entity analyzing functionality |
OrmException.php | Class | Derived exception |
OrmExceptionHandler.php | Class | Exception handling related functionality |
OrmMapping.php | Class | Mapping functionality |
OrmPersister.php | Class | Persisting functionality |
OrmStatement.php | Class | Statement related functionality |
OrmTransaction.php | Class | Transaction related functionality |
OrmTypeUtil.php | Class | Type analysis functionality |
OrmUtil.php | Class | Common utility functionality |
Files | / | src | / | Type |
File | Role | Description |
---|---|---|
AbstractType.php | Class | Abstract database type |
IType.php | Class | Database type interface |
MySQL.php | Class | MySQL database type |
Postgres.php | Class | PostgreSQL database type |
Sqlite.php | Class | Sqlite database type |
TypeFactory.php | Class | Database type factory |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
complex-tests (9 files) | ||||
failure-tests (6 files) | ||||
Model (13 files) | ||||
simple-tests (2 files) | ||||
_files (4 files) | ||||
AbstractDatabaseTestCase.php | Test | Abstract test case | ||
demo.php | Example | Example | ||
MySqlAbstractDatabaseTestCase.php | Test | Test case abstraction | ||
PostgresAbstractDatabaseTestCase.php | Test | Abstract test case for postgresql |
Files | / | tests | / | complex-tests |
File | Role | Description |
---|---|---|
ComplexTest.php | Test | Complex unit test |
EntityListTest.php | Test | Referenced entity unit test |
MySQLComplexTest.php | Test | Unit test for MySQL complex tests |
MySQLEntityListTest.php | Test | MySQL test version of entity list unit test |
MySQLPersistComplexTypesTest.php | Test | Unit test for complex type mapping in MySQL |
PostgresComplexTest.php | Test | Unit test for postgresql |
PostgresPersistComplexTypesTest.php | Test | Unit test for complex type mapping in Postgres |
ReferencesTest.php | Test | Unit test for referencial persistence and retrieval |
SimpleReferenceTest.php | Test | Relationship many-to-one unit test |
Files | / | tests | / | failure-tests |
File | Role | Description |
---|---|---|
DuplicateIdTest.php | Test | Test duplicate id behaviour |
FailureTest.php | Test | Failures unit test |
InvalidConnectionSettingsTest.php | Test | Unit test for invalid connection settings |
InvalidModelTest.php | Test | Unit test for invalid model |
InvalidReferenceTest.php | Test | Unit test for invalid mapping |
InvalidTypeTest.php | Test | Another failing unit test |
Files | / | tests | / | Model |
File | Role | Description |
---|---|---|
AnnotatedGuestBookModel.php | Test | Annotation test model |
Author.php | Test | Another unit test model |
BlogPost.php | Test | Referenced entity test model |
BlogUser.php | Test | Referenced entity test model |
Book.php | Test | Another unit test model |
GuestBookModel.php | Test | Test model |
InvalidModel.php | Test | Test entity containing errors |
InvalidReferenceModel.php | Test | Testing model for invalid mapping |
MockedModel.php | Test | Test model |
NoteModel.php | Test | Test model |
ReferencedGuestBook.php | Test | Entity for referenced tests |
User.php | Test | Entity for referenced tests |
ValidNoteModel.php | Test | Test entity for valid tests |
Files | / | tests | / | simple-tests |
File | Role | Description |
---|---|---|
NonAnnotationTestTest.php | Test | Unit test for non-annotated entities |
SimpleTest.php | Test | Simple unit test |
Files | / | tests | / | _files |
File | Role | Description |
---|---|---|
blog-seed.xml | Data | Referenced entity test data |
guestbook-seed.xml | Data | Test data |
notes-seed.xml | Data | Test data |
referenced-guestbook-seed.xml | Data | Dataset for testing reference retrieval and persistence |
caribu-2017-08-22.zip 65KB | |
caribu-2017-08-22.tar.gz | |
Install with Composer |
Needed packages | ||
Class | Download | Why it is needed | Dependency |
---|---|---|---|
PHP Generics | .zip .tar.gz | Logging & Interpolation | Required |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Related pages |
API Documentation Documentation for the API of Caribu |
Build and test results Jenkins page which performs tests and checks |
Documentation Documentation and tutorials how to use caribu |