Download the PHP package redgem/servicesio-bundle without Composer

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

ServicesIOBundle

ServicesIOBundle is a Symfony bundle that provides a way to easily build a services provider.

ServicesIO basically introduces two components :

Install the bundle

First of all, add and enable ServicesIOBundle in your project.

Add it in composer :

composer require redgem/servicesio-bundle:1.0.*

All set.

ServicesIO Model

The model will help you to read and decode trees structures (such as json) passed, for instance, as requests to your controllers.

documentation of the Model component to come later

ServicesIO View

You are probably used to Twig to build and render your HTML views on your projects.

The aim of ServicesIO is to be able to get something as powerful and efficient for data trees that Twig could be for HTML.

Overview

ServicesIO view provide you the ability to create :

Here is what you need to know before starting :

The basics : create your View

Now, let's see that in action with a short example.

To make it easy to read, I will remove all code that is not related to our topic.

Let's create a small example project : 2 entities and 2 controllers.

The Doctrine entities :

I assume to have 2 users : author and visitor and 3 entries for messages : message1, message2, message3.

Here are the controllers (without their return calls) :

Based on that, we now have to create the View elements for decorators and entities, and call the rendering from the controllers.

Let's complete first the messageAction's View, with a ServicesIO view class.

A basic View class has to :

We are here creating a simple tree with an Item object that containt 3 childrens : id, title, description to display our 3 corresponding message fields.

Finally, let's make the controller calling and rendering it :

The rendering service to call in ServicesIOBundle is called Redgem\ServicesIOBundle\Lib\View\Service.

The call takes 2 arguments :

The single variable sent as a parameter in the controller is accessible as $this->params['single'] in the view class.

Let's call it for the first message for example !

Nice, we now have the json representation of the MessageView class tree !

We can now replicate it for the listing action :

Let's call it, and :

Excellent !

Partials views and fragment controllers

We have a problem. We did repeat ourselves between the 2 classes to create the partial view of a message.

Fortunately, there is a solution, : to create a reusable element.

As yu can see, a reusable element is a totaly regular View class. That mean, you may use it to render directly a controller if you want to.

Finally, we use it on our SingleView and ListingView :

When calling the partial() method to get the subtree from there, it will pass for you the current context (i.e params you sent from the controller) merged with the params you add in the second method argument.

Of course, the json final rendering is still exactly the same.

Let's now enrich the data response everywhere with a new UserView :

and

A single request will now display :

In addition to to partial() method, a controller() method is available. Instead of calling just a view, it will call a whole Symfony controller as a fragment.

Its prototype is :

function controller($controller, $params = array())

with :

The response will be handle on that way :

And one more thing :

methods are available as well. They just use the container to call a Symfony service or a parameter.

View extensions

We now want to decorate our response with the connected user on the top of it. It's easy to do with this controller() method.

I assume that the user is correctly authenticated by the Security component :

And I add that to my views :

A single request will now display :

And my problem of repeating myself is back... on the global decorator. I have created twice the main object with visitor and response.

We can solve it by changing our way of thinking. Instead of having only one class to build the tree, let's split it into 2 elements :

First of all, let's create the decorator thing. It's still a regular View class :

There is a new third argument on the set() method. This third argument is a string, and set up a name for the placeholder option. The placeholder is an entry on the tree that can be replaced later by an another value.

In case of placeholder, the second value (null here) is a default value that will be displayed if the placeholder is not filled.

We can now transform our SingleView and ListingView to use this decorator :

We can see two differences :

You can of course chain how many levels oh hierarchy you want with getParent() and define placeholders into all of them.

getParent() usually return a string. It can also return an array :

In this case, the first actually implemented View class will be chosen.

Why all those fancy stuffs ?

Why doing that ? You may say it would be easier to use the regular extends PHP word for classes, and avoiding using viewpath, and you would be right. But ServicesIO view do provides you an easy, flexible, and clear way to build some view reusables pieces.

So Finally, we can call our controllers :


All versions of servicesio-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 redgem/servicesio-bundle contains the following files

Loading the files please wait ....