Download the PHP package tatter/roster without Composer

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

Tatter\Roster

Bulk name lookup for database relations in CodeIgniter 4

Coverage Status

Quick Start

  1. Install with Composer: > composer require tatter/roster
  2. Create a Roster class
  3. Load high-performance names: <?= service('roster')->user(1) ?>

Description

Roster solves a common, niche problem in an elegant way: quick access to display names for entity relations without requiring database lookup. An example... Your e-commerce app allows users to list their own products along with their username. To display the full product page, traditionally you would either need a database JOIN to fetch the usernames along with each product, or rely on a third-party solution like Object Relation Mapping (ORM) to load the related information. Roster simplifies and optimizes this by preloading batches of object names and caching them for convenient on-the-fly access.

Installation

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

Or, install manually by downloading the source files and adding the directory to app/Config/Autoload.php.

Usage

The Roster service handles locating and interacting with your Roster classes, so all you need to do is create some Rosters. All Rosters must meet a few criteria to be discovered:

BaseRoster

BaseRoster defines the three methods that your class must implement:

See the BaseRoster file for more details.

ModelRoster

Most of the time Rosters will be fetching information from the database. In order to make this more convenient and reduce repetitive code this library comes with an intermediate support class, ModelRoster. If your Roster aligns with an existing Model then simply extend the ModelRoster class and supply these required fields:

Displaying

Once your Rosters are configured, use the service with the Roster name as the method and the ID of the item as the sole parameter:

Example

You are developing a blog. At the bottom of every post is a comments section where logged in users may post replies. Being the bright developer you are, you decide to use Tatter\Roster to handle the display and save on expensive database joins for every page.

First let's handle displaying the username next to each commet. You already have UserModel so we can use the ModelRoster to make it easier. Create app/Rosters/UserRoster.php:

That's it! ModelRoster handles retrieving the values based those properties. Now in our comment HTML block we can use the Roster service to display each username:

Let's do our blog tags next: under the post title we want to display each tag for this post. Unfortunately tags are in the format "[General] Specific" so no single field will work for the display. We can still use the ModelRoster but instead specifying the field we will provide our own determining method. Create app/Rosters/TagRoster.php:

Now our blog post header looks much cleaner:

Finally, our blog is going to display a sidebar menu with post-relevant links to partners. This data will come from a third-party API, which would be an expensive call to make on every page load so we create a Roster for it. Because the data source is not a Model we need to make our own extension of the Base Roster. Create app/Rosters/LinkRoster.php:

A little bit more code, but using BaseRoster gives a lot more control about where the data comes from and how it is formatted. You've probably already figure this part out, but let's finish off our links with their HTML menu:


All versions of roster with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
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 tatter/roster contains the following files

Loading the files please wait ....