rand(Ø)

> beautiful code & photos

about <

Posts tagged: php

To rewind, or ! (to rewind)

Lately, I was missioned to integrate a vendor PHP SDK that is transport-agnostic as it implements HTTPlug. Pretty cool.

Everything went well until I found out that the SDK used a response reader method helper which is:

/**
 * @param ResponseInterface $response
 *
 * @return stdClass
 */
private function handleResponse(ResponseInterface $response)
{
    $this->setRateLimitDetails($response);

    $stream = $response->getBody()->getContents();

    return json_decode($stream);
}

First issue: I can't pick the response format, I'm forced to deal with the object deserialization version of the JSON payload. This is okay but not completely since the structure of the JSON may vary if my peers

> Continue Reading

Link ID fields in EasyAdmin

If you also use EasyAdmin and are exhausted by clicking twice to see an entity ID when on the entity index page, you can use this small tweak to have your index page generate the detail page link on the ID field.

For this, simply override the template crud/field/id.html.twig.  
The original value is currently this:

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{# this template is used to display Doctrine entity primary keys #}
{{ field.formattedValue }}

Instead, you could replace its content with this:

> Continue Reading

cURL: forward POST over HTTP redirections

Recently, I've been stuck on a Web service call that wouldn't be called as supposed to be. When having troubles with WS, it's very important to dump client request and server response.

Using cURL withing PHP, I couldn't understand why my code was building a POST request and cURL returned me a GET request instead when the URI was getting a 301 redirection.

Turned out that it was a configuration issue because the URI wasn't the right one. Thanks to the config team!

What cURL says

When curl follows a redirect and the request is not a plain GET (for
> Continue Reading

Wordpress to Ghost

Today For the past 2 weeks, I've been trying to move out from my beloved Wordpress blog to this new, shiny and hipsterish blog plateform called Ghost.

So, two big moves:

The longest part wasn't to have Ghost up and running but to import all my Wordpress shit into this baby's DB. Ha, a long story that involved automated and manual work.

Import WP data into Ghost

At first, I tried the Ghost Wordpress Plugin which exported well my WP data but I

> Continue Reading

PHP: Compile a PECL extension in 64 bits when your compiler runs 32 bits

At my job, I use a Solaris distribution as a development server and the package manager doesn't propose the Xdebug package so I need to use the PECL command, which is fine. But, the PECL manager uses the system compiler which compiles binaries with 32 bits flags although my LAMP stack is 64 bits linked.

No other choice to compile manually my extension and after a few hours of hell (yes, I'm not a C pro :cwy:), I found how to compile correctly my extension.

So, if one day you need to compile a PHP extension in a different architecture,

> Continue Reading

PHP: Utiliser l'autoloader de Composer avec Atoum

Chers amis Français, en ce temps de Forum PHP (que j'ai suivi de très loin — outre Atlantique), je suis en train de rédiger une documentation technique (et aussi un peu philosophique) sur l'implémentation de l'intégration continue au sein de ma boîte.

Comme je n'avais encore jamais utilisé Composer, ici l'occasion se présente bien et comme je souhaite apporter une French touch au boulot grâce à Atoum, j'ai décidé qu'on l'utilisera pour tester nos modules Magento :).

Le but de cet article est très simple : utiliser Atoum avec le loader de Composer en prenant compte d'une code source namespacé ou pas.

Composer

> Continue Reading