Archive for the ‘ Code ’ Category

Josso & PHP

I recently had the pleasure, if you would like to call it that, to implement JOSSO with PHP at my work. I quickly learned a few things about the process of setting up Josso with PHP, that aren’t well documented, and as such I am going to share my findings.

Downloading
Let’s start with downloading the PHP library for Josso. Most people will head straight to the SF.net repository for Josso and look for the PHP link. Well, let me save you the headache, it ain’t there. The PHP library is stored inside of the josso main package (currently josso-1.7.zip as of this writing). The main package by-the-way is 80+ MB. You are looking for roughly 30Kb of files inside that zip.

Inside the zip you will find tons of files, and folders . Let me guide you to where the PHP files are: (after unzipping)

\josso-1.7\josso\core\src\plugins\php\php

No, the double php is not a typo. Inside of that directory you will find three class files, a config file, a couple of login/logout views, the security check, and the josso file. Be forewarned there is also a nusoap directory, and this thing will cause some headache if you are not prepared.

Installation
Unless you have full control of your server that you are installing the JOSSO + PHP interface on, you will not have access to add Josso to the php.ini file to make is autoload on every single page. For this I really suggest using a MVC with Front Controller setup. This allows you to force the user through a single point to access any part of your site, and thus eliminates the need to make Josso autoload for every single php file on your site.

SOAP
Finally I want to talk about Josso’s implementation of SOAP. On their PHP site they write:

In case of using PHP5 be sure of disabling the native SOAP support in order to avoid conflicts with the SOAP API used by JOSSO.

That is 100% completely not needed. Here is why. The SOAP class they do use doesn’t touch the SOAP class from PHP, and as such it can simply have all references changed. I simply loaded all the files from Josso into Eclipse and did a find and replace on soapclient (the actual class that conflicts) and renamed it to josso_soapclient. There were only a handful of places to change this, maybe 10. Once they were renamed the Josso + PHP experience was quite simple.

Example Scripts
Lastly I want to quickly mention that when you load the sample scripts provided by Josso, you will get errors. Apparently some of the methods have changed since they wrote the Josso examples. I have submitted my changes to the Josso project, and I hope that they will be included as they only make sense. So if you get errors, just go into the code and look to see if 1) the method exists anywhere, and 2) find a similar method and call it.

Conclusion
I don’t want to sound as though I am bagging on Josso at all, instead I am just letting people know the problems I had, and how I fixed them. The rest of the setup was really quite simple. For Single Sign-on, Josso is great.

Update
So another small annoyance I found while using Josso was that when you send a bad login to Josso, Josso will hijack your user experience. I was passing the “josso_back_to” string, and I couldn’t think why it wouldn’t send the user back. It turns out that Josso only uses the “josso_back_to” string when there is a valid login, and a second parameter of “josso_on_error” is required for bad logins (or errors).

Book Review: PHPEclipse: A User Guide

PHPEclipse: A User Guide is a quick read. Having already worked with Eclipse for PHP development the book didn’t present any drastic or life changing additions to my technique with Eclipse.

The book is greatly geared toward the newest of PHP programmers, ones still looking to make a mark in the world, or those who are looking to escape the claws of another IDE and want to know what Eclipse and PHPEclipse are all about. Shu-Wai does and excellent job of explaining what Perspectives and Views are and how they work together to make up the meat of PHPEclipse.

Each chapter is full of quick information about how to setup a specific aspect of Eclipse to better work with PHP development. Chapters 3 and 4 explain how the IDE displays information about your application to you, and where to look for more information. Chapters 5 through 8 explain different plug-ins (CVS, Debug, Deploying code) and explain how they work integrated with Eclipse. The best part of each of these latter chapters is they explain in detail how to get the particular plugin installed and configured. It was a fresh and welcome look at plugins and how they work.

What peaked my interest in the book were two things. The first was Appendix A which explains more about where to get more plugins and information about the plugins. The second was the overview of Eclipse. A short history and explanation of how Eclipse came to be what it is today. I was particularly interested in the plugin development, which is built right into Eclipse.

Although the book is short, and a quick read, if you are thinking about picking up Eclipse and using it, you should get this book and read through it while you are in the process.