Download the PHP package czim/laravel-service without Composer

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

Laravel Service

Latest Version on Packagist Build Status Latest Stable Version SensioLabsInsight

Basic framework for making standardized but flexible webservice classes.

Version Compatibility

Laravel PHP Package
5 - 8 5 - 7 0.9
7 - 8 7.2+ 1.0
9 7.2+ 1.1
9 8.0 2.0
9 8.1 3.0

Install

Via Composer

Unless you're using auto-discovery, add this line of code to the providers array located in your config/app.php file:

Requirements

To use the SshFileService, you will require the libssh2 PHP extension.

Usage

Services

The basic approach to using a Service in three steps:

  1. Instantiate a Service
    • passing in the defaults (optional)
    • passing in an interpreter instance (optional)
  2. Perform a call() on the service instance

For a simple SOAP service, this might be as follows:

Available Services

See this list of examples for more information.

RestServices and HTTP methods

One thing to look out for is a potential confusion over the 'method' when using the RestService. The $method parameter in the service's call() does not refer to the HTTP Method (GET, POST, etc). For cross-services compatibility purposes it is used to set the URI path instead, since that best corresponds to the 'method' for SOAP calls. The HTTP Method is to be separately set on the service before making the call, with setHttpMethod().

So making a DELETE call to /comments/13 may be set up as follows:

If not set, the default HTTP method is POST.

Alternatively, the HTTP method may be configured per-call without affecting the default, by setting it in a ServiceRequest parameter:

The order of precedence is:

  1. HTTP method set in request for call
  2. HTTP method set in default request for service
  3. HTTP method defined in service directly

Interpreters

Services always return a ServiceResponse for each call. The content of the response (mainly the data accessible through getData(), but also its other properties) is determined by the ServiceInterpreter instance set for the service. ServiceInterpreters are responsible for interpreting and converting the raw data retrieved to whatever (standardized) format and response content you prefer.

Standard available interpreters:

It is recommended to extend these or roll your own interpreter for complex services. I often build interpreters that use czim/laravel-dataobject to convert raw data into validatable, specific data objects. See the AbstractServiceInterpreter source for hints and useful methods.

Interpreter Decorators

Some decorators for interpreters are provided:

They follow the standard decorator pattern for interpreters, so they may be used as follows:

The AbstractValidationPreDecorator may be extended to easily set up validation of raw data before the decorated interpreter does its business. Likewise the AbstractValidationPostDecorator may be extended to validate the ServiceResponse object returned after the interpreter has treated the response.

Service Collection

By way of wrapping multiple services, this package offers a ServiceCollection. This is a simple extension of the Illuminate\Support\Collection, which may only be used to store ServiceInterface objects.

You can set one up just as you would a normal Collection:

Note that calling get() on the collection for a non-existant service will throw an exception; as will trying to store something other than a ServiceInterface in it.

Notes

BeSimple SoapClient

The BeSimpleSoapService service class is set up to use the BeSimple SoapClient.

The only thing required to use it is to include the package:

DOMDocument parsing as an alternative to SimpleXml

When using the DomDocumentBasedXmlParser, note that this will not return a SimpleXml-type object, but a DOMElement. To sensibly use this, convert it to an array using the DomObjectToArrayConverter. This means that when rebinding or injecting one of these, treat them as a pair.

Note that the DOMDocument method is slower and uses significantly more memory. If you have no specific reason to use this, stick to the default.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-service with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
czim/laravel-dataobject Version ^3.0
guzzlehttp/guzzle Version ^7.0
illuminate/support Version ^9
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 czim/laravel-service contains the following files

Loading the files please wait ....