Download the PHP package granadaorm/builder without Composer

On this page you can find all versions of the php package granadaorm/builder. 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 builder

Builder

Latest Stable Version Build Status

Class builder for models and controllers for the Granada ORM

Installation

Install easily with composer:

I highly recommend getting the form component instead, which also pulls builder:

Introduction

GranadaORM is a fantastic ORM but creating and managing the classes for each table in a large system can get tedious. Builder addresses this problem using a script that analyses the (MySQL only for now) database structure and automatically builds the required classes for models and controllers.

An added bonus is that a modern IDE will get autocomplete for the elements and functions available in the models.

Overview

When working with GranadaORM there are two main modes of interaction with the models: Building a query, and working with results of a query.

The builder creates a level of classes extending \Granada\Model to add functionality and split these two modes of operation:

Hierarchy

Let's use an example of a table of People. It has the fields:

myapp_person
id
first_name
last_name
created_at
deleted_at

The \Myapp\Person class is created that extends \Myapp\BasePerson which extends a class you define in your configuration, to allow for system-wide additions. That class needs to extend \Granada\Builder\ExtendedModel which extends \Granada\Model

Added functionality

To make Granada models more useful, the following functions and features have been added for all models created and managed by Builder:

Usage

Here's some examples of how you can use the classes to interact with the database through Granada even easier.

Querying

Using the example above, let's get the list of the 50 people who were most recently updated:

Now let's get the list of all the people with the surname "Smith"

For more functions available, see the list at the top of the and files.

Set up for building

The build system needs to know where to put the files, how to access the database and what to namespace to use if you haven't named your table names with the namespace prefix.

Create the config file

Create a json config file with contents similar to the following:

That config file should be put somewhere that your script can run it. You can see that in the example the output dir is the same directory as the config file.

Add the directory to the autobuilder

In your system index.php or wherever your main entrypoint / config include, add an autoloader for these created classes to be loaded on access. For example you could use something like this - adjust your folders appropriately

In the example above, we have a structure where the model and controller classes to extend sit in the and under that is the folder which is where the config file sits, and all the classes are created.

Doing the actual build

Run

It may take a minute if your database has a large number of tables.

Note that the builder creates four files for each table. For the table above, the builder will create:

Only the files in _base are managed automatically - the other two are meant for you to modify the class specific to the data in that table and should be managed by your version control system. You should ignore the _base folders and auto-generate those on the server with each system update.

More details

Look in the generated source code, and in the Builder ExtendedModel and the tests to see how you can use the system.


All versions of builder with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
cakephp/chronos Version ^2.0
doctrine/inflector Version ^2.0
latte/latte Version ^2.10
granadaorm/granada Version ^3.1
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 granadaorm/builder contains the following files

Loading the files please wait ....