<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ruckuus / php-activerecord-service-provider example snippets
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',
));
namespace App\Model;
class User extends \ActiveRecord\Model {
static $has_many = array (
array('problem'),
array('luck')
)
}
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);
}
}
}