Is it possible to use Zope object database from PHP? - php

as from Title.

Possible? Yes, everything is possible :)
But it is sensible? Hardly, it is too Python specific, I'm afraid, and therefore it would not be any fun to write a parser for Python data structures in PHP.
If you really need to do this, then I would recommend building a middle-layer in Python, which would then expose your ZODB over an interface that is usable in PHP. One possiblity would be using HTTP for the protocol and then JSON, XML or whatever else your heart desires for payload.

you could call the XML-RPC interface methods from PHP

Related

PHP framework that provides equivalent to asp.net .ASMX?

I have searched and everything I get looks to be about a PHP app consuming an .aspx web service but that's not what I'm looking for.
I may be overlooking something obvious and would be happy to hear that but that doesn't mean I haven't tried.
I'm a .Net developer by platform, a developer by trade 20+ years and will admit that I'm spoiled by the ease of .Net
That said, an ASP.Net .asmx web service is quite literally a single file that might be pure soap (but it's so well hidden that I don't know) but I can use them with jQuery AJAX calls effortlessly. Methods exist that have parameters (basic types or complex objects defined by classes in my project) and I can call those methods at a single url, pass in my JSON and .Net gives me an object to work with. I do what I need, then return an object matching the methods return type and all the HTTP/JSON/ENCODING/DECODING is done for me so I only need to worry about the JSON client-side, working with my classes server side, and treating the methods like any other server-side method.
Does a library/framework exist for PHP that provides that same sort of ease? From my reading, I think that 'routing' is a related concept but that term isn't one I know in the .Net context so assume I know nothing but basic PHP skills (nothing but server side syntax, operators, data types, etc..)
I want to learn to love PHP but this could be make/break for me because everything I do now ends up being client-side JS/DOM and server-side data management. Very little use for actually manipulating the HTML returned to the client (Call it Google-style web apps).
If it helps define what I'm looking for, I use Telerik Kendo DataSource a lot and need the easiest way to focus on my client-side code with Kendo and actual business logic/db server-side.
Slimframework.com looks to be the closest thing I've found so far but it's not clear to me if it's intended for what I'm needing or if it's perhaps just a common tool that would help get me there. I'm hoping for something clearly more complete.

Mapper between json and php class

I'm starting a new project that uses couchbase (a noSQL database that stores objects in json format), together with php.
The thing is that it would be really easy to work with them both if I could have something that maps json into one of my own php classes (and vice versa).
Do you know any library for that?
One way to start is to look (or use) the "Basement" Library that is available here:
https://github.com/Basement/Basement
This library uses json_decode/encode.
Hope that will help you.
You may use our JSONmapper to map from JSON to your PHP classes.
It unfortunately does not support mapping back (yet).
Tug already mentioned Basement, which will provide that functionality of "models" in the near future like you know it from ORM systems.
Aside from that, mapping your plain old php objects to JSON is very easy, thanks to the nature of json_encode/decode. Since you can pass it an arbitary object and it will store it as JSON, thats basically the only thing you need at hand. If you need more infos about JSON and PHP, my blog post is a good start: http://nitschinger.at/Handling-JSON-like-a-boss-in-PHP
If you use Basement, it makes it a little bit easier for you since it allows you to transform PHP types into JSON behind the scenes automatically (or write your own mapper if needed).
If you have a specific example that you want to build, let me know and I'd be happy to provide an example!

Easiest RPC client method in PHP

I've been asked to help a friend's company to bring up a web application. I have very limited time and I reluctantly accepted the request, at one condition. As most of the logic goes on in the back-end, I suggested that I would finish the complete back-end only, allowing a front-end developer to simply interface with my backend.
I plan to do the back-end in Java EE or Python (with Pylons). It does not really matter at this point. I plan to have my back-end completely ready and unit-tested, so that my input will hardly be needed after my work is done.
I know they have a PHP programmer, but as far as I could tell he is a real rookie. I want him to basically interface with my backend's services in the easiest possible way, with no way of him "stuffing" it up. It's basically a CRUD-only application.
I could implement the backend as accessible through a webservice such as XML-RPC or SOAP. Even a RESTful API could be possible.
However, my main objective is to make something that complete "noob" PHP programmer can easily interface with without getting confused. Preferably I do not even want to talk to him because I generally have an extremely busy schedule, and doing "support calls" is not something I am willing to do. Which approach should I choose? I would welcome any suggestions and inputs!
I would personally choose a REST API, probably with a JSON response. SOAP and XML can be a bit heavy-handed for simple services, and even the most novice web developer understands the concept of accessing a basic URL, even if they don't grok the overall concept of REST. There are myriads of ways to work with URLs in PHP, so I'm sure they'd be able to come up with something, even if it was a hack job instead of a nice client package.
I would also likely choose JSON encoding and decoding, as it's generally fairly straightforward, while XML parsing can be a bit more daunting.
I would also write up at least some basic documentation on the service, no matter what formats you choose. Otherwise there's no way you will escape support calls. Your target consumer must have a reference of the remote actions available to him, or a method to discover those actions. It would probably take you 10 minutes to whip up some example code when it's ready, and those 10 minutes could save you a lot of emailing.
Definitly go with a rest-like implementation, and return query string formatted output.
Just remember that php will turn array like variables into an array on the php side.
Take a query string for your parameters
Input:
p1=v1&p2=v2....
Output:
output1=var1&output[0]=var2;output[2]=var3
Accessing this in php is then a simple as
<?
$request['myparam1'] = param;
...
$webService ="http://path.to.service?".http_build_query($request);
parse_str(file_get_contents($webService),$response);
// response is now an array with you response parameters in it
// $response['responseParam1'], reponse['responseParam1'] etc
?>
parse_str
http_build_query
Been there, done that.
Backend in Django, frontend in PHP by a 'we do pages' contractor. i whipped up a REST-like API using JSON, provided them with a couple of 5-line PHP functions to access my service as a key-value store.
After a couple of false starts (where they tried a contrived and redirections scheme instead of using the functions i sent them), they got it and everything went smoothly after that.

Use TIBCO General Interface with PHP, is that posible?

Can I use TIBCO General Interface with PHP? Or better, with CakePHP? If it's possible, how can I do that? Maybe some documentation in the web? (I search but I don't find anything). Thanks.
Yes, a PHP application can generate all of the data formats which GI uses, such as raw XML, JSON, or SOAP.
Have a look here: http://uk.php.net/soap to get started writing PHP-based web services

passing variables between flex and php

i am new to flex development my question is How do i pass variables between flex 3 and a mysql database using php? i was told the best way is to AMFPHP but that seems like an over kill or may be not am not sure.. any ideas?
I'd use json over xml since json will transfer less bytes and php's json_encode($object) is quick and easy.
I'd use json over amfphp because json is general purpose. For example, I can create a web service for flex or javascript by returning json.
You might have a look at this article for comparison between json, amfphp, and xml. Also, here is a nice tutorial on flex, php, and json.
AMFPHP is not really being actively developed. The best alternative right now is to use Zend_Amf http://wadearnold.com/blog/?page_id=155, which is supported by both Zend and Adobe.
Don't be scared by the need for Zend Framework components. The framework is modular, and you can use your own custom php classes for accessing data without having to incur the Zend Framework learning curve.
The great thing about using AMF is that since it is a binary data transfer, it's very fast.
Also, working with XML or even JSON, is an annoying extra step if you just want your flex app to get results data an api call. If, for some reason, you need to also handle outputting data to xml or json, that can easily be added to your app by extending or creating new controllers/services that translate the data from arrays and objects to xml or json
There's a few choices open to you. Essentially, it boils down to how you'd like to deal with the data on the PHP side of the fence.
The two I'd spend time investigating would be simple XML (my first preference) and AMFPHP.
XML:
Flex can work very easily with XML data, even mapping it automatically to/from ActionScript objects (generically, or with something like the xobj project on GoogleCode, to typed instances). Similarly, there's plenty of support available for working with XML in PHP code.
AMFPHP:
AMFPHP gives you way to pass typed ActionScript objects over the wire to your PHP code. There's tooling included in the AMFPHP project that makes working with MySQL on the PHP side easy too.
If you are doing a simple query, I would pass your data as plain POST data. You can do this using HTTPService component in Flex. On the PHP side I would respond with an XML string and set the HTTPService resultFormat to "e4x" (Ecmascript for XML), for an easy object-like manipulation of the result data.
Here is the livedocs reference for HTTPService: http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html
For more complicated queries/operations, there is also the option of using the Flex RemoteObject with AMF as the data protocol. On the PHP side you can then use the zend framework AMF component to communicate.
Here is the livedocs reference for RemoteObject: http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_4.html
And the download page for Zend AMF: http://framework.zend.com/download/amf

Categories