Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Orm Laravel Package

atlas/orm

View on GitHub
Deep Wiki
Context7

Getting Started

Integrations

If you are using Symfony 4, you can get started by installing the Atlas.Symfony bundle.

If you are using Slim 3, please see the cookbook recipe for Atlas.

Otherwise, read below for the stock installation instructions.

Installation

This package is installable and autoloadable via Composer as atlas/orm. Add the following lines to your composer.json file, then call composer update.

{
    "require": {
        "atlas/orm": "~3.0"
    },
    "require-dev": {
        "atlas/cli": "~2.0"
    }
}

(The atlas/cli package provides the atlas-skeleton command-line tool to help create data-source classes for the mapper system.)

Note:

If you are using PHPStorm, you may wish to copy the IDE meta file to your project to get full autocompletion on Atlas classes:

cp ./vendor/atlas/orm/resources/phpstorm.meta.php ./.phpstorm.meta.php

Skeleton Generation

Next, you will need to create the prerequsite data-source classes using Atlas.Cli 2.x.

Instantiating Atlas

Now you can create an Atlas instance by using its static new() method and passing your PDO connection parameters:

use Atlas\Orm\Atlas;

$atlas = Atlas::new(
    'mysql:host=localhost;dbname=testdb',
    'username',
    'password'
);

Optionally, you may pass a Transaction class name as the final parameter. (By default, Atlas will use an AutoCommit strategy, where transactions have to be managed manually.)

use Atlas\Orm\Atlas;
use Atlas\Orm\Transaction\AutoTransact;

$atlas = Atlas::new(
    'mysql:host=localhost;dbname=testdb',
    'username',
    'password',
    AutoTransact::CLASS
);

Alternatively, use the AtlasBuilder if you need to define a custom factory callable, such as for TableEvents and MapperEvents classes.

use Atlas\Orm\AtlasBuilder;
use Atlas\Orm\Transaction\BeginOnRead;

$builder = new AtlasBuilder(
    'mysql:host=localhost;dbname=testdb',
    'username',
    'password'
);

// get the ConnectionLocator to set read and write connection factories
$builder->getConnectionLocator()->...;

// set a Transaction class (the default is AutoCommit)
$builder->setTransactionClass(BeginOnRead::CLASS);

// set a custom factory callable
$builder->setFactory(function ($class) {
    return new $class();
});

// get a new Atlas instance
$atlas = $builder->newAtlas();

Next Steps

Now you can use Atlas to work with your database to fetch and persist Record objects, as well as perform other interactions.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky