CIM/SMI-S Client with PHP - php

I'm working on a web interface to pull information from storage arrays. I'd like to use SMI-S There are Java CIM clients I can use (SBLIM CIM Client), but I'd really like there to be a way for PHP to pull information via CIM. Can anybody point me in the right direction? Is there a way I can, say, send a request over http (port 5988) and just parse out an xml response?
If anybody can suggest a better way that'd be great as well. Thank you.

I don't know of a CIM client written directly in PHP, but normally you can integrate packages written in Perl or Python into your server side PHP.
You could also integrate a command line CIM client into PHP, e.g. cimcli from OpenPegasus, but parsing the output of a command line client may not really be convenient.
I would recommend against writing your own CIM-XML parser - there are many details to observe in the specs (DSP0200, DSP0201), this would definitely be a major undertaking.
For Python, there is the PyWBEM CIM client which works very well, even though there is not much activity on the project. Also, there is the PowerCIM CIM client for Python, which is newer but I did not use it yet. PowerCIM provides the CIM classes as Python classes, while PyWBEM provides generic Python classes such as CIMInstance or CIMClass. Just two different styles to deal with, for integration into a next higher layer such as PHP it seems to me you'd be better off with the generic style provided by PyWBEM.
There is a Perl interface on top of the OpenWEM client, but I don't have experience with that.
Andy

SMI-S calls to get array details may use GetInstances() or EnumerateInstances(), which are basically predefined methods. These methods come with library such as OpenPegasus. If you are successful in including the required libraries, then you can create the client variable, connect to the CIM server and invoke the required method.
If you are specifically using OpenPegasus, you may need to know how to use C++ in PHP as the former is implemented in C++. Refer http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/

Related

Using Ruby library in PHP application

I am working on a PHP project that makes use of MLB's Gameday data. There appears to be a pretty solid Ruby library for working with data. I don't particularly want to rewrite the entire library in PHP, so I was wondering if anyone had any suggestions for a good way to interact with the Ruby scripts from my PHP application.
I'm starting to think that I'll need to write some sort of command line Ruby script that'll interact with the Ruby classes and output the data in a format usable by PHP (JSON, XML).
Are there any better ways to do accomplish this?
Another option is to use Gearman, written by the the same team that brought us memcached. It has PHP and Ruby bindings.
You'd create a daemon in Ruby that exposes functions to Gearman, then have your PHP code call those functions through Gearman. No Apache needed.
(Boy, I'm on a Gearman plugging streak. I wish I was getting paid for it!)
Rather then a command line interface, I'd suggest outputting data in JSON format and requesting that data via PHP & CURL.
If you needed to you could even write a REST interface for it pretty easily.

How to connect Jms from PHP ?

I am trying to implement my sites little chat function like facebook uses. I used Html, PHP, JQuery and Apache. I made before some exaples with JMS but I couldn't figure out how to send message to a JMS server with PHP?
For JMS I used Weblogic.
You have a few options. Let's go through them in order of worst to not-worst.
First is Quercus, a PHP implementation in Java. PHP code running in Quercus can instantiate Java classes and call methods on them, just like they were PHP objects. You'd be able to work with JMS in the same way you'd work with it in Java. I have no experience with this one.
Second is the PHP/Java Bridge. It's a bit more complex to get working, but it effectively works the same way as Quercus, code-wise. You'd be able to work directly with any old Java API. I have experience with this one, and it wasn't pleasant. Java processes ended up hanging around in a zombie state after the corresponding Apache+PHP child exited. We eventually had to write a cron script to clean up all working Java processes nightly, otherwise the server would eventually run out of available memory.
Third would be looking at different JMS providers, like ActiveMQ. Why? Because ActiveMQ supports many messaging APIs, including Stomp, a language-agnostic messaging API that happens to have a PHP extension. It's possible that Weblogic can speak Stomp, but I was unable to determine if this is the case. The only Google results were for Weblogic + ActiveMQ integration.
Fourth would be not thinking about JMS. JMS is a Java solution. PHP ain't Java. There are plenty of message queue systems out there that work well with PHP. ActiveMQ is only one example. I personally prefer Gearman. Gearman was originally designed to perform sharded remote procedure calls, but it works equally as well for simple message passing, and has a PHP extension as well as bindings for most other languages under the sun.
Just to give two other options: OpenMQ (using HTTP) and PHPMQ
(My two cents about the accepted answer)
Great answer, one quibble: Gearman is great for Remote Procedure Calls, but as to message passing, JMS is much more robust (persistence, etc.). Aim for JMS in some way would be my suggestion.

Is it necessary to have a wsdl file for the creation of a webservice in php?

My question is needed for some basic understanding of webservices and more specificly
in conjunction with php
I would like to know, if it is necessary to have a wsdl file for the creation of a webservice or is that just something that is usefull to third party's that want to access the webservice?
Also, it's generated automaticly in .net environments, but for php it's a bit more difficult.
What are my options?
The thing I am after is to create a jm2ee application on my mobile that sends data to the webservice from time to time.
I read somewhere that you have to supply the arguments when there is no wsdl file.
What is meant by that? and/or what are the implications of that?
Thanks in advance, Richard
I would like to know, if it is
neccasary to have a wsdl file for the
creation off a webservice
No, it is not necessary (at least, not in PHP) : it helps others know how to access your webservice (which methods, objects, ... should be used), but a WS can be called even if it doesn't export a WSDL
For PHP, yes, it is a bit difficult to get a WSDL (many classes don't generated them :-( ) ; still, you can generatd it with another tool (there are tools in Eclipse to write WSDL files, for example).
There was PEAR::Soap that was able to generate WSDL from PHP code (but you had to write down many lines of code to get it right) -- considering there is a class included in PHP 5 to work with SOAP, I wouldn't recommend using this one, anyway.
For more informations, you can have a look at :
SoapServer ; especially, if you look at the documentation of SoapServer::__construct, you will notice it can work both in WSDL and non-WSDL mode
Zend_Soap
If you are creating both the client and the web service, then there is no particular need to futz with SOAP, WSDL, or any of that jazz.
Just use the basics of the web: the client can use GET to fetch information, and POST to send it. You can format the data any way you like, but JSON and XML are common, well-defined approaches.
If you'd like inspiration for your API design, check out some popular examples:
Twitter API
Flickr API
all the Google APIs
all the Yahoo APIs
That's enough to get you started, but if you're curious about the design philosophy, you can read up on Representational State Transfer or REST.
WSDL file documents in a machine readable (XML) format what the methods (and args for methods) offered by a web service. You do not need a WSDL file if you know what the methods and args are - though WSDL is very good to have as a means of making the web service public interface more 'contractified', if you will.
To the best of my knowledge the PHP library does not have functions to automagically generate a WSDL file for you.
Web service support is built into php5, your best starting place is the documentation.
Some sources will use the term "webservice" as synonymous with SOAP. That is a misnomer. SOAP is a particular protocol - It is one way to create a web service. There are other technologies available. In general SOAP is the preferred standard with in Java and .net, but it is a bad fit outside of this sphere. If you have the option, I would strongly suggest that you consider either xml-rpc (Which is simpler and has better direct support on php) or a http-based service (Also called REST based).

Flex with PHP

I'm new to Flex and done a few application with only client side programming. Now I'm trying to do the back-end stuff using PHP. Can some one explain where(which folder) to put the PHP file for the Flex file to communicate with PHP. I'm using Flexbuilder 3 IDE.
Thanks
Flex will not access your PHP script via the filesystem, you have to invoke your PHP script via a web server. The easiest solution is to use XML as in your data transport language. But you can get fancy and use something like BlazeDS
This all really depends on what you want. I would make a very different recommendation if you wanted to simply poll the server occasionally than if you wanted to have a regular interface between the two.
If you are simply polling the server, I would recommend simply using the HTTPRequest class. It will allow you to create POST and GET data and serve to communicate relatively well.
On the other hand, if you are looking to have a more complicated set of communications between the server and the SWF, your best bet is the RemoteObject class with either AMFPHP, WebOrb, or an equivalent (we use WebOrb where I work). This has the benefit of allowing you to have objects of similar name/type in both Flex and PHP, meaning that communication can be made a good deal more comprehensive.
(If you are working this way, email me cwATallen-poole.com and I can give some pointers so that you do not have insane compiler arguments for Flex).
The next option is to use the XMLSocket class, but that seems to be a bit more intense than what you are looking for.
You may want to take a look at AMFPHP too, pretty handy.
Try XAMPP.Very useful.
The new Flash Builder 4 (product formerly known as FlexBuilder) supports connecting to PHP services out of the box. The use the Zend Framework to do it, and will install the framework to your test webserver for you whenever you go to setup a data service.
Adobe video tutorials:
Part 1
Part 2
Another good, non-video tutorial

PHP and Java EE Backend

Can I use Struts as a backend and PHP as front end for a web application? If yes, what may be the implications.
The first thing to came to mind is Quercus (from the makers of the Resin servlet engine), as Jordi mentioned. It is a Java implementation of the PHP runtime and purportedly allows you to access Java objects directly from your PHP (part of me says "yay, at last").
On the other hand, while I have been itching to try a project this way, I would probably keep the separation between Java EE and PHP unless there was a real reason to integrate on the code-level.
Instead, why don't you try an SOA approach, where your PHP "front-end" calls into the Struts application over a defined REST or SOAP API (strong vote for REST here) over HTTP.
http://mydomain.com/rest/this-is-a-method-call?parameter1=foo
You can use Struts to build your entire "backend" model, dealing only with business logic and data, and completely ignoring presentation. As you expose the API with these URLs, and you are basically building a REST API (which may come in handy later if you ever need to provide greater access to your backend, perhaps by other client apps).
Your PHP application can be built separately (and rather thinly), calling into the REST API (perhaps using Curl) as if it would call into a database or some native PHP class library.
Anyway, that's what I'd do. But, if you do use Quercus, please post how it went.
I don't know much about Java, but I remember running into Quercus a while ago. It's a 100% Java interpreter for PHP code.
So yes, you could have PHP templates on your Java app. Update: see Quercus: PHP in Java for more info.
What do you mean by backend and and frontend?
If you mean using Java for the admin side of your site and PHP for the part that the public will see then there is nothing stopping you.
The implications are that you will have to maintain two applications in different languages.
I think what you mean is you want to use PHP as your templating language and structs as your middleware (actions etc).
I would imaging the answer would be no, not without some kind of bridge between the structs session and the PHP.
If you say change x to 3 in java in a structs action, you couldn't just go <?php echo x ?> or whatever to get the value out, you would need to transfer that information back and forth somehow.
Submitting would be OK though, I would imagine.
Not recommended though.

Categories