neoxygen / neo4j-neoclient

Simple PHP HttpClient for the Neo4j ReST API with Multi DB Support
MIT License
121 stars 138 forks source link

How to handle server plugins #45

Closed mehmetbilgin closed 9 years ago

mehmetbilgin commented 9 years ago

Hi Christophe,

I wrote a server plugin and I want to call this new plugin using your bundle. Is it possible? Do I need to create a new command (that extends AbstractCommand)?

ikwattro commented 9 years ago

Hi @mehmetbilgin ,

The best way to do it is to write a neoclient extension. I need definitely to write a blog post about how to do it and link it into the doc.

In the meantime, you may want to look how I created extensions for spatial and timetree :

https://github.com/neoxygen/neoclient-spatial-extension

https://github.com/graphaware/neoclient-timetree-extension

mehmetbilgin commented 9 years ago

I managed to write the extension looking at the examples you gave, but my unchecked extension returning json stream. Looks like setting header option "Accept: application/json" (in GuzzleHttpClient.php) causing error with the request.

ikwattro commented 9 years ago

Hello @mehmetbilgin ,

Thanks for your feedback. You mark a good point, the client is made to send only json http requests. And I'm aware now that somebody may have the need to send anything else than json.

I will try to find a "temporary fix" for the 2.x version of the client. Thanks for using the library and to report here.

ikwattro commented 9 years ago

@mehmetbilgin

I have pushed a new branch "custom-headers", if you would like to see if it fit your needs it would be cool.

How it works ?

In the execute method of your new Command you can now pass a last parameter to the ->process() method call :

public function execute()
    {
        return $this->process(self::METHOD, self::PATH, $this->prepareBody(), $this->connection, null, $this->queryMode, $headers);
    }

$headers has to be an array of headers where keys are the header name and value the header value, it will override default headers the GuzzleHttpClient has.

e.g. :

$headers = ['Content-Type' => 'application/text'];
mehmetbilgin commented 9 years ago

Thanks for the quick fix. I will be able to try it tomorrow and let you know the outcome.

ikwattro commented 9 years ago

Thank you.

mehmetbilgin commented 9 years ago

Sorry for delayed response. I've tested it and it works. Are you planning to merge it back to 2.x branch?

ikwattro commented 9 years ago

Cool. Yes I will merge it in 2.x

ikwattro commented 9 years ago

This has been merged into master, and released with 2.1.14 tag