Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Using Illuminate Database With Eloquent in Your PHP App Without Laravel
Jan 26, 2017 @ 09:51:05

The TutsPlus.com site has posted a new tutorial showing you how you can use the Eloquent ORM from Laravel without having to use Laravel itself. There's already functionality built into the popular database interface that makes it possible, it's just a matter of turning it on.

Illuminate is Laravel’s database engine minus Laravel. It comes bundled with the Eloquent ORM in Laravel. If you would like to build your PHP apps with ORMs and prefer not to use Laravel, this tutorial is for you.

In this tutorial, we are going to build the back end for a Q&A App with PHP, Illuminate Database, and the Eloquent ORM.

They start the post with a list of requirements and a brief outline of what functionality the end result will include. With that defined the tutorial starts in on the directory structure of the application and the Composer configuration to pull in Eloquent and its requirements. Next up is the code to define the connection credentials and (raw) SQL to create the tables in the database. The database "capsule" is created and the code is shared to create simple controllers and matching models for users, questions, answers and upvotes. They show how to use relationships to get the linked objects between tables and how to perform update and delete operations.

tagged: illuminate database eloquent laravel outside tutorial capsule

Link: https://code.tutsplus.com/tutorials/using-illuminate-database-with-eloquent-in-your-php-app-without-laravel--cms-27247

Rob Allen:
Using Eloquent in Slim Framework
Apr 07, 2016 @ 09:45:31

Rob Allen has a quick post showing how to use Eloquent in a Slim framework application to work with your database queries and functionality.

Eloquent is one of the easier ORMs to get started with, so let's look at how to use and test it within a Slim Framework application. [...] Eloquent is quite a nice implementation of the Active Record pattern. If that meets your needs, then it is easy to use within a Slim Framework application, so go for it!

He walks you through the set up of the Eloquent package via a Composer require and update your Slim configuration with the database settings. He then includes the few lines you'll need to use the "capsule" manager to integrate it with the Slim structure. He also talks about testing models and shows how to create some simple tests with PHPUnit and a bit of mocking.

tagged: slimframework eloquent database capsule composer tutorial

Link: https://akrabat.com/using-testing-eloquent-in-slim-framework/