Download the PHP package internetpixels/repository-manager without Composer

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

Repository manager with simple SQL Query builder

Manage your entities and repositories with this simple repository manager. An all in one solution for building repositories and entities.

License Build Status Maintainability

Basic examples

Create your first entity

The entity will contain the data for a specific object (Also known as DAO) and will mediate between the application and the database. An entity has to use getters and setters.

<?php

namespace YourProject\People;

use InternetPixels\RepositoryManager\Entities\AbstractEntity;
use InternetPixels\RepositoryManager\Entities\EntityInterface;

class PersonEntity extends AbstractEntity implements EntityInterface
{

    /**
     * @var string
     */
    private $name;

    /**
     * @var int
     */
    private $age;

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     */
    public function setName(string $name)
    {
        $this->name = $name;
    }

    /**
     * @return int
     */
    public function getAge(): int
    {
        return $this->age;
    }

    /**
     * @param int $age
     */
    public function setAge(int $age)
    {
        $this->age = $age;
    }
}

Create your first repository

A repository will handle all data transfers between an entity and your database. The repository will build queries to execute those actions.

Note: The entityName needs to map to your database table name.

<?php

namespace YourProject\People;

use InternetPixels\RepositoryManager\Entities\AbstractEntity;
use InternetPixels\RepositoryManager\Factories\EntityFactory;
use InternetPixels\RepositoryManager\Repositories\AbstractRepository;

class PeopleRepository extends AbstractRepository
{

    protected $entityName = 'people';

    public function update(AbstractEntity $entity)
    {
        $query = $this->queryBuilder->new($this->entityName)
            ->update([
                'name' => $this->dataManager->sanitize($entity->getName()),
                'age' => $this->dataManager->sanitize($entity->getAge()),
            ])
            ->where(['id' => $entity->getId()])
            ->limit(1)
            ->get();

        return $this->executeQuery($query);
    }

    /**
     * @param array $data
     * @return PersonEntity
     */
    protected function dataToEntity(array $data): PersonEntity
    {    
        /** @var PersonEntity $entity */
        $entity = EntityFactory::create('people');

        $entity->setName($data['name']);
        $entity->setAge($data['age']);

        return $entity;
    }
}

Register the Data manager

You only need to register the RepositoryDataManager and the new entity in the EntityFactory. The Data manager needs an (existing) Mysqli connection.

$mysqliConnection = new \Mysqli(
    $config['mysql.host'],
    $config['mysql.user'],
    $config['mysql.password'],
    $config['mysql.database']
);

$repositoryDataManager = new \InternetPixels\RepositoryManager\Managers\RepositoryDataManager($mysqliConnection);

// Add all your entities:
\InternetPixels\RepositoryManager\Factories\EntityFactory::register('people', new PersonEntity());

$peopleRepository = new PeopleRepository($repositoryDataManager);

Usage of the repository

In a service of your application you can implement the PeopleRepository and use them for basic CRUD actions or your custom implementations.

$peopleRepository = new PeopleRepository($repositoryDataManager);

// Get all records:
$people = $peopleRepository->read();

// Update a person
$person = EntityFactory::create('people');
$person->setId(1);
$person->setName('Person name');
$person->setAge(26); // update the age

$peopleRepository->update($person);

// Delete a person
$person = EntityFactory::create('people');
$person->setId(1);

$peopleRepository->delete($person);

Usage of the SQL Query builder

This package contains a simple query builder. Please use the functionality to prevent basic SQL issues.

// Sanitize input in a repository before pushing to the database:
$safe = $this->dataManager->sanitize($entity->getName());

// Build a new select query in a repository
$query = $this->queryBuilder->new($this->entityName)
            ->select()
            ->get();

// Build a new select query in a repository with a limit
$query = $this->queryBuilder->new($this->entityName)
            ->select()
            ->limit(2)
            ->get();

// Build a new select query in a repository with a where clause
$query = $this->queryBuilder->new($this->entityName)
            ->select()
            ->where(['age' => 25])
            ->get();

All versions of repository-manager with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 internetpixels/repository-manager contains the following files

Loading the files please wait ....