2017 © Pedro Peláez
 

library php-activerecord-service-provider

A PHPActiveRecord Service Provider for Silex

image

ruckuus/php-activerecord-service-provider

A PHPActiveRecord Service Provider for Silex

  • Wednesday, March 19, 2014
  • by ruckuus
  • Repository
  • 1 Watchers
  • 7 Stars
  • 2,816 Installations
  • Perl
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 2 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

ActiveRecordServiceProvider

A PHP ActiveRecord ServiceProvider for Silex., (*1)

History

I was about to use [Available ActiveRecord Extension] (https://github.com/RafalFilipek/ActiveRecordExtension/blob/master/ActiveRecordExtension.php), but then I realised that registerNamespace() is deprecated in later version of Silex. This work is experimental, it has a minimum functionality to "work"., (*2)

Fetch

The recommended way to install ActiveRecordServiceProvider is through composer., (*3)

Just create a composer.json file for your project:, (*4)

{
    "require": {
        "ruckuus/php-activerecord-service-provider": "dev-master",
        "silex/silex": "1.0.*@dev"
    }
}

Parameters

  • ar.model_dir - Path to where model folder is located ( without trailing slash )
  • ar.connections - Array of connections (name => connection). Connections examples:
    • mysql://username:password@localhost/database_name
    • pgsql://username:password@localhost/development
    • sqlite://my_database.db
    • oci://username:passsword@localhost/xe
  • ar.default_connection - default models connection.

Register

use Silex\Application;
use Ruckuus\Silex\ActiveRecordServiceProvider;

$app = new Application();

$app->register(new ActiveRecordServiceProvider(), array(
    'ar.model_dir' => __DIR__ . '/App/Model',
    'ar.connections' =>  array ('development' => 'mysql://root@localhost/database_name'),
    'ar.default_connection' => 'development',
));

Usage

Create your model in __DIR__ . '/app/Model'. Eg., (*5)

namespace App\Model;

class User extends \ActiveRecord\Model {
    static $has_many = array (
        array('problem'),
        array('luck')
    )
}

In your application:, (*6)

use App\Model\User;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;

class UserProvider implements UserProviderInterface
{
    public function loadUserByUsername($username)
    {
        $user = User::find_by_username(strtolower($username));

        if ($user->dirty_attributes()) {
            throw new UnsupportedUserException(sprintf('Bad credentials for "%s"'), $username);
        }
    }
}

For more informations check the website of PHP ActiveRecord. Its wiki., (*7)

The Versions

19/03 2014

dev-master

9999999-dev https://github.com/ruckuus/ActiveRecordServiceProvider

A PHPActiveRecord Service Provider for Silex

  Sources   Download

MIT

The Requires

 

orm database silex activerecord

19/03 2014

0.0.1

0.0.1.0 https://github.com/ruckuus/ActiveRecordServiceProvider

A PHPActiveRecord Service Provider for Silex

  Sources   Download

MIT

The Requires

 

orm database silex activerecord