Download the PHP package nahid/presento without Composer

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

Presento

A data preparing and presenting package for PHP.

Why Presento?

Presento is a simple but powerful tools for preparing and presenting data. When we build an API based application, we need to transform the data before present it through the response. This package will make this task easier for you.

Not clear enough?

Don't worry, you'll get better idea from the Usage examples.

Requirements

Installation

Install the package using composer:

Usage

Presento serves two important purposes. one is Presentation and another is Transformation of the data.

Let's see some examples to understand how to use it.

We'll use the following data set to show the examples. Let's say we've this data set fetched from some data source and need to do some transformation or modifications before sending it to the response.

Simple Presentation Example

When sending this data to the API response, we only want to send the id, name, email, type, is_active and projects.

We can simply do that by preparing a Presenter for this like following.

And you might already guessed how to use it, right?

It'd show something like this:

Pretty simple, right?

'key' aliasing in Presentation example

Let's say you want to change some of the 'key' to something different, like the id key to user_id . How can you do that?

Just do the following.

This will format the data like following:

Deep traversing in Presentation example

You can easily dive deep and get data from a nested level by using . (dot) notation.

Let's say you want to show the name of the first package as the top_package in your data.

This is how you do it.

This will format the data like this:

Notice the top_package key in the data.

Simple Transformer Example

Let's say our UserPresenter is like this:

And we want to show the user_id as hashed value instead of an incremental integer value as it is in our database. That means we want to transform the user_id.

To do that we need to create a Transformer Class like this:

Notice that, as we will transform the user_id property, we named our transformer method as getUserIdProperty. So, if you want to transform the name property too, you need to just create another method in this class named getNameProperty and add the transformation logic inside it.

Now, we need to let know the Presenter how to Transform the data before presenting it.

To do that, we need to add the following method in the UserPresenter class.

So, our final output would be:

Ain't it easy, mate?

Nested Presenter Example

You might notice that there is a collection of projects in our data set. If each project is a separate resource, you might have a separate Presenter for that. Like this:

Can you use this Presenter for each of the projects in the Users data?

Hell Yeah! Just do this:

Now, each of the project in the list of projects in Users will be presented as defined in the ProjectPresenter.

Base Data format conversion Example

As you have seen that, the data set we have used till now is a plain Array. But some times it might not be the case. You might need to work with something different, like Eloquent Model of Laravel framework. In that case, you can simply add a method called convert in your Presenter to convert the Base data to an Array format.

Let's see an Example:

That's it.


All versions of presento with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
ext-json Version *
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 nahid/presento contains the following files

Loading the files please wait ....