Menu
  • HOME
  • TAGS

How to update Apigility from 1.0.3 to 1.1.1?

zend-framework2,composer-php,updates,apigility

Why do you think the latest version of Apigility is 1.1.1? https://packagist.org/packages/zfcampus/zf-apigility shows 1.0.3 (which you already have) as the latest version, as does the Github repository. It's the skeleton application, that's at version 1.1.1....

How to build nested responses in an Apigility driven application with a ZfcBase-DbMapper based model?

php,zend-framework2,one-to-many,datamapper,apigility

I have finally found a solution. (Thanks once again @ poisa for his solution suggestion on GitHub.) In short, the idea is to enrich the (projects) list items with nested (image) items lists on the hydration step. I actually don't really like this way, since it's too much model logic...

How to get serviceManager to work on a class zf2

php,zend-framework2,apigility

That's because the ServiceLocator is injected through a mechanism called 'setter injection'. For that to happen, something (e.g., ServiceManager) needs to call a setter for a class, in this case setServiceLocator. When you directly instantiate Auth that's not the case. You need to add your class to the service locator,...

unwanted response text in rest apigility

php,zend-framework2,apigility

got it in return response in apigility: so change my code in userapiResource.php public function create($data) { $client = new Client(); $client->setUri('http://xxxx/xxxx/public/mob-app/client/update'); // set some parameters $client->setParameterPost(array('userid'=> $data->userid,'price'=>$data->price)); // POST request $client->setMethod('POST'); $respons=$client->send(); $respons->getContent(); $returnArray = []; $final_array = [ 'content' => json_decode($respons->getContent()) ]; $returnArray['data'] =...

How to access two similar but located in different API in a single Apigility project?

rest,apigility

I'm guessing based on your question that you've got ApiOne with a route to /user and ApiTwo with a route to /user? The problem is that they are not different routes. ZF2 is going to use (I believe) the one that is defined last in the combined configuration file. If...

Testing with OAuth2 and Postman

zend-framework2,postman,apigility

Click on Headers then add Authorization as Header and Bearer 62f6109dcbce42b38f9117b21529faf30fc0ee86 as Value ...

php cURL giving blank response body

php,curl,zend-framework2,apigility

$response_body = json_decode($body); curl_close ($ch); return array($response_header, $response_body); http://ca1.php.net/manual/en/function.json-decode.php Return Values Returns the value encoded in json in appropriate PHP type. Values true, false and null are returned as TRUE, FALSE and NULL respectively. NULL is returned if the json cannot be decoded or if the encoded data is...

Password protecting Apigility admin UI without htpasswd

zend-framework,zend-framework2,apigility

You don't need password protection for ApiGility UI. Access should only be allowed in the Dev environment. php public/index.php development enable <- to enable the UI php public/index.php development disable <- to disable the UI If you consist of having password protection for it. Then you can add an event...

How to set up different databases / database adapters for multiple versions in Apigility?

database,rest,zend-framework2,apigility

In order to use multiple DB adapters, one simply need to create an appropriate configuration block in the (global.php for the generall setting like driver and local.php for the credentials) -- it can be done manually or over the Apugility GUI (Dashboard -> Database Adapters) global.php return array( 'db' =>...

Apigility and oAuth for users

oauth,zend-framework2,apigility

What you're likely looking for is the "password" grant type. In this scenario, you will have a way of registering users and their passwords, and then a "login" screen of sorts. This login screen will send the following information: username password client_id -- this will be the OAuth2 client ID...

Does Apiglity provide a buil-in error handling and logging?

error-handling,zend-framework2,error-logging,apigility

It handles error rendering if you use ApiProblem objects to encapsulate your errors. It doesn't handle logging out of the box, you'll have to add your application's logging strategy yourself....

ApiGility - Getting validation errors with PUT

zend-framework,zend-framework2,apigility

You need to supply your data as http body (payload) in json format. Make the call to the URI without the query params. https://cloud.mysite.dev:8890/api/updatecart/1 { "prod_id": 1, "quantity": 1, "update_type": 1, "tax": "0.00" } Also make sure you supply the right request headers: Accept: application/json Content-Type: application/json ...

How to use multiple versions at the same time in an Apigility app with Doctrine?

doctrine2,zend-framework2,version,dbconnection,apigility

The following section of your config: [ 'db'=>[ 'adapters' => [ 'DB\\myproject_v1' => [], 'DB\\myproject_v2' => [], ] ] ] configures an abstract factory that registers the service names DB\\myproject_v1 and DB\\myproject_v2 with db adapter instances. It is the part of the configuration below that actually assigns the adapter to...

How to register a custom hydrator in Zend Framework 2?

php,zend-framework2,apigility,hal

What you did in your edit using getHydratorConfig was correct, the error message you're seeing is caused because within your factory method you're attempting to fetch your image service from the hydrator plugin manager. The solution is simple, as with other plugin managers you need to call getServiceLocator() on the...

How / Why does the dummy Apigility REST application wotk without end points?

php,rest,zend-framework2,zend-studio,apigility

The Apigility documentation (REST Service Tutorial -> Create a REST Service -> [infobox] Code-Connected vs DB-Connected services) provides the perfect answer: Code-Connected vs DB-Connected services When you create a Code-Connected service, Apigility creates a stub "Resource" class that defines all the various operations available in a REST service. These operations...

OnDispatch event in Service Constructor

php,zend-framework2,apigility

It seems to me that you have two different goals here. 1. Store a header variable from a route event. 2. Get a variable into the constructor function of a class To answer 1. You can make a listener class and attach this class to your eventManager. This would look...

How to make Zf2 Apigilty accept client request with no Accept set in header

php,zend-framework2,apigility,content-negotiation

You could write a listener in which you check the Accept header of the incoming request. If no Accept header is set you can add an Accept header with a default value; for example application/json. So something like: /** * Set empty accept header by default to `application/json` * *...

Apigility as OAuth2 Resource Server with remote Authorization Server

php,oauth,oauth-2.0,apigility

the interface/protocol/API between a Resource Server and an Authorization Server is not standardized in OAuth 2.0; work is underway to do that as an extension: https://tools.ietf.org/html/draft-ietf-oauth-introspection-03 this means that there is extremely little chance that you can use Apigility with another Authorization Server unless they happen to implement the same...

ZF2 - Apigility not creating new api

zend-framework2,apigility

What I did to resolve this was to create an autoload file: mydev.local.php and to include the following in it: <?php return [ 'zfc_rbac' => [ 'protection_policy' => \ZfcRbac\Guard\GuardInterface::POLICY_ALLOW ] Problem solved. thanks! ]; This means that any route that is not in my guards is not protected... of course...

How to expand error codes in documentation in Apigility?

php,documentation,apigility

How to customize error response in Apigility Apigility works seamlessly together with ZF Api Problem for error handling. Creating an error response from a controller or listener is as simple as: use ZF\ApiProblem\ApiProblem; ... return new ApiProblem(500, "My Internal Server Error"); The status titles for common errors are set here...

ApiGility - JSON decoding error: Syntax error, malformed JSON in PostMan

postman,apigility

The problem is that you're trying to send parameters as form data. Instead you'll want to send it as "raw." Click on the "raw" tab in the Headers section. Then enter your data as a JSON string. {"quantity_accumulation": "1"} ...

Jquery and ApiGility login strategy

javascript,jquery,apigility

1. Yes you can, as long as you use a properly configured (secure) https connection. By using a security certificate you will ensure encryption of the data being sent and received by the client and it will be unreadable when intercepted. 2. When using implicit grant you will still need...

Apigility - Invalid content type specified

configuration,zend-framework2,apigility

The solution in this case was to run a composer.phar update which resolved the issue.

Enabling Zend Developer Tools toolbar causes database connection errors

php,doctrine2,zend-framework2,apigility,zend-tool

You are only showing Db configs. You need a Doctrine config something like this: <?php return array( 'doctrine' => array( 'connection' => array( // default connection name 'orm_default' => array( 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', 'params' => array( 'host' => 'localhost', 'port' => '3306', 'user' => 'username', 'password' => 'password', 'dbname' =>...

Doctrine - How to hydrate a collection when using query builder

doctrine2,doctrine-odm,apigility

The Answer to this is as I have above: I have this working although I am not keen on it as I hit the DB twice. The first time to build the array (Which is the entire result set which could be very big for some applications) and then the...

How to get the Basic HTTP Authentication working for an Apigility application?

php,authentication,zend-framework2,basic-authentication,apigility

As of the new version of Apigility (not sure exactly which one, but greater than 1.0) there's the ability to create multiple Auth adapters and associate each API to a different Auth adapter. If you've created an auth adapter (Authentication on the top -> Adapters -> New Adapter) you'll have...

ZF2 - Formatting Routes

zend-framework2,apigility

In this case, it would seem the problem is to do with htaccess or apache. The simplest solution has been to encode the url using: base64_encode($url) which can be de-coded at the other end.

ZF2 & Apigility - Correct way to setup GET and POST RPC services

zend-framework2,apigility

In general you POST your new entities on the collection endpoint so in your case /api/verify/merchant. The server will respond with a new resource with a self href for the newly created Merchant. This href will be formatted like /api/verify/merchant[/merchant_code] where merchant_code will be the identifier for the newly added...

Apigility is requiring the route_identifier_name for Code-Connected REST POST Entity

php,api,zend-framework2,apigility

If you create a new resource on a Restful API you do a post on the collection route. So you should add your POST method to the collection_http_methods array. This is totally according to Restful specifications. 'collection_http_methods' => array( 0 => 'GET', 1 => 'POST', ), I think if you...

Apigility API structure

php,api,structure,apigility

1. Yes, you can use several modules with their own module.config.php files like you would normally do inside a ZF2 application. It is also useful to split into several config files. You can for example create: metadata.config.php, controller.config.php and inputfilter.config.php And then merge the config files in your module.php Module::getConfig...