1. Go to this page and download the library: Download valu/valuso library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
valu / valuso example snippets
// Fetch broker from main service locator
$serviceBroker = $serviceLocator->get('ServiceBroker');
/**
* Initialize Worker, but tell the IDE to treat $service
* as an instance of UserService class
* @var $service \ValuUser\Service\UserService
*/
$service = $serviceBroker->service('User');
// Call 'create' operation
$service->create('administrator');
// Assume that service with ID 'ZendLogger' is registered
// to ServiceManager
$serviceBroker
->getLoader()
->register('ZendLogger', 'Log');
$serviceBroker->service('Log')->err('Something went wrong');
use ValuSo\Annotation as ValuService;
class UserService {
/**
* Create user
*
* @ValuService\Context("http-put")
* @ValuService\Log({"args":"username","level":"info"})
* @ValuService\Trigger("pre")
* @ValuService\Trigger("post")
*/
public function create($username, array $specs)
{
// create a new user
}
}
$loader = $serviceBroker->getLoader();
$loader->registerService('HmacAuth', 'Auth', new HmacAuthenticationService());
$loader->registerService('HttpBasicAuth', 'Auth', new HttpBasicAuthenticationService());
$loader->registerService('HttpDigestAuth', 'Auth', new HttpDigestAuthenticationService());
// Authenticate until one of the respondents returns
// either boolean true or false and retrieve that value
$isAuthenticated = $serviceBroker
->service('Auth')
->until(function($response) {return is_bool($response);})
->authenticate($httpRequest)
->last();
class ExtendedUserService {
public function findExpiredAccounts() {
// run some special find operation
}
}
$loader = $serviceBroker->getLoader();
$loader->registerService('ExtendedUserService', 'User', new ExtendedUserService());
$serviceBroker->service('User')->findExpiredAccounts();
$config = [
'valu_so' => [
// Set true to add main service locator as a peering service manager
'use_main_locator' => <true>|<false>,
// See Zend\Mvc\Service\ServiceManagerConfig
'factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'invokables' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'abstract_factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'shared' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'aliases' => [...],
'cache' => [
'enabled' => true|false,
'adapter' => '<ZendCacheAdapter>',
'service' => '<ServiceNameReturningCacheAdapter',
<adapterConfig> => <value>...
],
'services' => [
'<id>' => [
// Name of the service
'name' => '<ServiceName>',
// [optional] Options passed to service when initialized
'options' => [...],
// [optional] Service class (same as defining it in 'invokables')
'class' => '<Class>',
// [optional] Factory class (same as defining it in 'factories')
'factory' => '<Class>',
// [optional] Service object/closure
'service' => <Object|Closure>,
// [optinal] Priority number, defaults to 1, highest number is executed first
'priority' => <Priority>
]
]
]
],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.