Download the PHP package bgillet/slim-orm without Composer

On this page you can find all versions of the php package bgillet/slim-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package slim-orm

Slim-Orm

This package contains a wrapper for to Idiorm & Paris ORM.

Requirements

This package is compatible with :

Installation

You have two options :

Configuration

In your Slim configuration, set your connections parameters as follow :

$config = array
(
    SlimORM::CONNECTIONS => array
    (
        SlimORM::DEFAULT_CNX => array
        (
            SlimORM::DSN => 'mysql:host=localhost;port=3306;dbname=slim1',
            SlimORM::USR => 'root',
            SlimORM::PWD => '',
            SlimORM::OPT => null
        ),
        'named_connection' => array
        (
            SlimORM::DSN => 'mysql:host=localhost;port=3306;dbname=slim2',
            SlimORM::USR => 'root',
            SlimORM::PWD => '',
            SlimORM::OPT => null
        )
    )
);

Here are explanations for each parameter :

All these constants correspond to parameters available in Idiorm or Paris. If there is one or more missing, you still may use the SlimORM::configure() static method detailed further. This is a shortcut to the Idiorm's configure() method. For more details about available parameters, please consult Idiorm's documentation at http://idiorm.readthedocs.org/en/latest/configuration.html or Paris' documentation at http://paris.readthedocs.org/en/latest/configuration.html.

How to use

Let's have a look to the sample code below :

<h1>SlimORM test page</h1>

<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require 'User.php';

use \BenGee\Slim\Db\SlimORM;

try
{
    // Configure connections through Slim's configuration array
    $config = array
    (
        SlimORM::CONNECTIONS => array
        (
            SlimORM::DEFAULT_CNX => array
            (
                SlimORM::DSN => 'mysql:host=localhost;port=3306;dbname=slim1',
                SlimORM::USR => 'test',
                SlimORM::PWD => '',
                SlimORM::OPT => null
            ),
            'named_connection' => array
            (
                SlimORM::DSN => 'mysql:host=localhost;port=3306;dbname=slim2',
                SlimORM::USR => 'test',
                SlimORM::PWD => '',
                SlimORM::OPT => null
            )
        )
    );

    // Create an instance of your Slim application

    $app = new \Slim\Slim($config);

    // Register the ORM in the app.
    // It will configure itself using settings set inside Slim's configuration array.

    SlimORM::register($app);

    // Get a reference to the 'user' table through Idiorm and get contents.

    $users1 = $app->db->table('user')->find_many();

    // Get a reference to you own 'User' model class through Paris and get contents.

    $users2 = $app->db->model('User', 'named_connection')->find_many();

    // Display results

    $app->get('/', function() use($users1, $users2)
    {
        echo '<h3>Test using Idiorm and accessing data directly using table name on default connection</h1>';
        echo '<p>' . count($users1) . ' users found</p>';
        if (!empty($users1))
        {
            echo '<ul>';
            foreach ($users1 as $user)
            {
                echo '<li>' . $user->username . ' (' . $user->id . ')</li>';
            }
            echo '</ul>';
        }
        echo '<h3>Test using Paris and accessing data using model class on named connection</h1>';
        echo '<p>' . count($users2) . ' users found</p>';
        if (!empty($users2))
        {
            echo '<ul>';
            foreach ($users2 as $user)
            {
                echo '<li>' . $user->username . ' (' . $user->id . ')</li>';
            }
            echo '</ul>';
        }
    });

    // Run the Slim app

    $app->run();
}
catch (\Exception $e)
{
    echo 'An exception occurred while testing !';
    echo '<div><pre>' . $e . '</pre></div>';
}

Here is expected result of the test :

Sample of expected test result

Use steps are :

  1. Add ORM connections and their parameters to Slim's configuration array.
  2. Create an instance of your Slim application.
  3. Use the SlimORM::register() method to configure and register the ORM inside you Slim app under $app->db.
  4. Then use whatever $app->db->table() or $app->db->model() method depending on which ORM you want to use (either Idiorm or Paris). Once you go a reference to a table or a model, you can use methods available in the corresponding ORM.

API

Class \BenGee\Slim\Db\SlimORM


All versions of slim-orm with dependencies

PHP Build Version
Package Version
Requires j4mie/paris Version ~1.5
slim/slim Version ~2.4
bgillet/slim-utils Version ~1.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bgillet/slim-orm contains the following files

Loading the files please wait ....