1. Go to this page and download the library: Download simple-as-fuck/orm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
simple-as-fuck / orm example snippets
/**
* you can put some implementation of abstract connection in your DI container
* than all repository can be loaded from DI
*
* @var \SimpleAsFuck\Orm\Database\Abstracts\Connection $connection
*/
$repository = new \App\Service\Database\SomethingRepository($connection);
$model = new \App\Model\Database\Something('example', 5);
$repository->insert($model);
$autoIncrementPrimaryKey = 1;
$insertedModel = new \App\Model\Database\Something('update_example', 5, $autoIncrementPrimaryKey);
$repository->update($insertedModel);
$insertedModel = $repository->selectByPrimaryKey($autoIncrementPrimaryKey);
$repository->delete($insertedModel);
/**
* abstraction with configuration you can create some adapter for config from your app
*
* @var \SimpleAsFuck\Orm\Config\Abstracts\Config $config
*/
/**
* you can inject custom connection into mysql database
*
* @var \SimpleAsFuck\Orm\Database\Mysql\Connection|null $connection
*/
/**
* you can inject custom directory generator and change what classes will generated
* by default models and repositories are generated with model-*, repository-* config.
*
* @var \SimpleAsFuck\Orm\Generator\Abstracts\DirectoryGenerator|null $directoryGenerator
*/
$generator = \SimpleAsFuck\Orm\Generator\Generator::createMysql($config, $connection, $directoryGenerator);
// same as composer cmd "composer orm:generate"
$generator->generate();
// same as composer cmd "composer orm:check"
$generator->check();
// same as composer cmd "composer orm:generate -- --i-am-not-stupid"
$generator->generate(false);
/**
* you must inject some structure loader and provide ModelStructure array,
* for every instance of ModelStructure should be created some class or classes in $directoryGenerator
* $generator instance will handle file system synchronization
*
* @var \SimpleAsFuck\Orm\Generator\Abstracts\StructureLoader $structureLoader
*/
/**
* you must inject directory generator with definition
* which classes will generated based on ModelStructure array
*
* @var \SimpleAsFuck\Orm\Generator\Abstracts\DirectoryGenerator $directoryGenerator
*/
$generator = new \SimpleAsFuck\Orm\Generator\Generator($structureLoader, $directoryGenerator);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.