Download the PHP package atelierspierrot/webservices without Composer

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

WebServices Engine

documentation A PHP engine to manage web-services easily.

How-to ?

The basis

The engine is designed as a sort of "MVC" application to handle new requests by developing your Controllers easily. All requests are handled by an interface, www/index.php by default, in which you can define some options values to fit your needs or environment.

The default arguments used by the front controller (GET or POST) are:

The response is a JSON table containing at least a status and a message entry:

{"status":0, "message":"Hello World !"}

Get method (default)

$ curl -i 'http://mydomain.com/webservices/?action=helloworld'

HTTP/1.1 200 OK
Date: Thu, 11 Jul 2013 09:57:40 GMT
Connection: keep-alive
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 40
Content-Type: application/json; charset=UTF-8

{"status":0,"message":"Hello World ;)"}

Post method

$ curl -i -d "name=Pierre" 'http://mydomain.com/webservices/?action=testPost'

HTTP/1.1 200 OK
Date: Thu, 11 Jul 2013 09:57:40 GMT
Connection: keep-alive
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 41
Content-Type: application/json; charset=UTF-8

{"status":0,"message":"Hello Pierre ;)"}

Return status

The FrontController is designed to return a status code as an integer following these rules:

Options

The WebServices\FrontController::create() method accepts a third argument to define a set of customized options:

Rewritting

The engine is designed to handle requests written with GET arguments like key=>value pairs or full URL written as a list of key/value pairs.

For instance, these followings are equivalent:

$ curl -i 'http://mydomain.com/webservices/?ws=MyController&action=custom'
$ curl -i 'http://mydomain.com/webservices/ws/MyController/action/custom'

This URL rewriting feature can be disabled setting the enable_url_rewrite option on false.

Logging

By default, the engine will log any request received and some of the PHP work done from it. The default path for log files is var/logs/ from the package root directory. This path can be defined with option log_directory.

The logging feature can be disabled setting the enable_logging option on false.

Customization

Installation of a WebServicesEngine environment

To prepare a package based on the WebServices, you will need Composer installed on your machine, and then you just need to run:

~$ php path/to/composer.phar create-project atelierspierrot/webservices YOURDIR dev-master --no-dev
...

~$ vim YOURDIR/composer.json
// add an entry in the 'autoload' of composer.json to reference your namespace, i.e.
"autoload": { "psr-0": { "WebServices":"src", "MyNamespace":"src" } }
~$ php path/to/composer.phar dump-autoload YOURDIR
...

~$ vim YOURDIR/www/index.php
// adapt the interface options to fit your needs
// reference your controllers to have a shortcut access to them

Then, you just have to create your src/MyNamespace/ directory and put your controllers in it.

That's it!

Key concepts

The only thing to do to write a new webservice is to create a new PHP class extending the \WebServices\Controller\AbstractController abstract class. As explained in previous section, you have to declare the actions of your controller by naming them like dosomethingAction().

For instance, consider a custom "MyController" controller with methods "indexAction()" and "customAction()". You will call each of these actions with requests:

$ curl -i 'http://mydomain.com/webservices/?ws=MyController'
$ curl -i 'http://mydomain.com/webservices/?ws=MyController&action=custom'

Write a "usage" information for a custom controller

Each controller can propose a "usage" string information defining the $usage_filepath property on the absolute accessible path of a usage file. The content can be parsed by the Markdown Extended parser if it is named with a .md extension.

You can write your usage contents in PHP as in this case, the current configuration settings are loaded as environment variables. The special variable $webservice_url is defined on the current interface URL. To do so, you MUST use a final extension .php (.md.php to use the Markdown parser).

The "usage" string is displayed fo each controller calling the usage action.

Referencing your custom controllers

You can develop as many new controllers you want and build a shortcut to access them by defining the controllers_mapping option table, which is constructed like shortcut => classname. For instance, to access a controller defined in class MyNamespace\MyController, you can write 'myctrl' => 'MyNamespace\MyController' and access it by URL http://.../?ws=myctrl.

Package environment

As they are mandatory, you can use one of the temporary directories of the package in your developments (they must be accessible for Apache user as they may be created by it):

Development environment

As the "WebServices" depends on them (they must be installed), you can use in your scripts all classes from the following third-party packages:

Development of the package

To install all PHP packages for development, just run:

~$ composer install --dev

A documentation can be generated with Sami running:

~$ php vendor/sami/sami/sami.php render sami.config.php

The latest version of this documentation is available online at http://docs.ateliers-pierrot.fr/webservices/.

Author & License

WebServices Engine

http://github.com/atelierspierrot/webservices

Copyright (c) 2013-2016 Pierre Cassat and contributors

Licensed under the Apache 2.0 license.

http://www.apache.org/licenses/LICENSE-2.0


Les Ateliers Pierrot - Paris, France

http://www.ateliers-pierrot.fr/ - [email protected]


All versions of webservices with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
atelierspierrot/patterns Version ~1.0.9
atelierspierrot/library Version 1.*
piwi/markdown-extended Version dev-master
psr/log Version dev-master
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 atelierspierrot/webservices contains the following files

Loading the files please wait ....