Download the PHP package efabrica/nette-repository without Composer

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

eFabrica Nette Database Repository

This extension enhances the static analysis of your Nette Database by providing typehinted entities (ActiveRows), queries (Selections) and repositories (services).

Installation

You can install this extension using Composer, the dependency manager for PHP:

To enable the extension, you need to register it in config:

Finally, you can run the repository code generation command to generate the necessary classes and files:

Usage

Entity

The Entity class is a subclass of ActiveRow that serves as a superclass for your entities. You can either use our code generation tool to create it automatically or write it manually.

Inserting an entity

Save array:

Classic:

Multi-insert:

Updating an entity

Classic:

Deleting an entity

Or, if you already have the entity available:

Scopes

Scope is a class that defines which existing behaviors are disabled for the Repository, Query and Entity.

The active Scope is passed down from Repository to Query and from Query down to Entity.

->withScope(Scope $scope) returns a clone of the object with the given scope applied.

->scopeRaw() returns a clone of the object with raw scope. Raw scope removes all behaviors.

->scopeFull() returns a clone of the object with full scope. Full scope keeps all behaviors. This is the default scope, unless you change the scope in repository's setup() method.

Example

To use the Scope as a container service, which may not be necessary in your case, please follow these steps:

And optionally implement shorthand methods for your queries:

Usage:

Code Generator

Code generation is fully optional, but it is recommended to use it.

To run the code generation, use this command:

For every table in the database, it will generate these classes in the /Generated/ namespace: (Example: person table)

These classes are always regenerated when you run the code generator. They should not be modified manually.

For every table in the database, it will also generate these classes outside of the /Generated/ namespace, but only if they don't exist. If they exist, they will not be overwritten:

These classes are not regenerated when you run the code generator. They are meant to be customized by you. If you want to regenerate them, you have to delete them first.

Ignoring tables

It is also possible to ignore some tables. To do that, you can modify the ignoredTables parameter in the config file:

Custom Inheritance

If you want to set different extends or implements for a generated class, you can do that by adding an entry into your config file:

This config schema is a bit verbose, but very intuitive once you see it and easy to read.

Behaviors and Traits

DateBehavior

This behavior automatically sets the created_at and updated_at columns to the current date and time when inserting or updating a row.

FilterBehavior

This behavior applies a default where() condition to every select query.

KeepDefaultBehavior

This behavior ensures that there is always at least one row with a truthy value in the default column. This is useful for flag columns.

SoftDeleteBehavior

This behavior marks a row as deleted by setting the deleted_at column to the current date and time instead of removing it from the table.

LastManStandingBehavior

This behavior prevents deleting the last row in the table that matches a given query.

TreeTraverseBehavior

This behavior manages the lft and rgt columns that represent the hierarchical structure of the table. It updates them automatically when inserting or updating a row.

SortingTrait

This trait adds methods to the repository for changing the order of rows, such as moveUp(), moveDown(), insertBefore(), and insertAfter().

CastBehavior

This behavior automatically casts values to the specified type when retrieving them from the database.

There are some predefined casts, but you can also define your own.

Events

There are several events that you can listen to in your repository: Insert, Update, Delete, Select, Load

To implement your own event subscriber, create a new class that extends Efabrica\NetteRepository\Subscriber\EventSubscriber and register it in the container. It will get automatically detected, since it extends the EventSubscriber.


All versions of nette-repository with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
ext-pdo Version *
doctrine/inflector Version ^2.0
nette/caching Version ^3.1
nette/database Version ^3.1 <3.2
nette/di Version ^3.1
nette/php-generator Version ^4.1.4
nikic/php-parser Version ^4.16|^5.0
symfony/console Version ^5.4|^6.0|^7.0
symfony/polyfill-php80 Version ^1.29
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 efabrica/nette-repository contains the following files

Loading the files please wait ....