Running ZendServerGateway on the embedded PHP 5.4 Server.

So you have discovered ZendServerGateway and you are like, “Wow, this makes web services easy”. However, you quickly discover that there is a little magic behind the scenes, and that this add-on works best within the context of Zend Server 6. That can be a little frustrating, especially if you or your organization does not use Zend Server 6. Never fear, there is a way around this “implied” requirement. In just a moment I will walk the reader through setting up the embedded PHP 5.4 webserver to utilize the ZendServerGateway. All the steps should easily translate to whatever environment you use for serving your PHP pages. I am going to assume a Window environment for development.

  1. Alright, I said you DON’T NEED to RUN Zend Server 6, but you will still need to download and install it on your workstation. This is so we can get a copy of the ZendServerGateway code that can be easily copied.
  2. Once you have downloaded and installed Zend Server 6, go to the C:\Program Files (x86)\Zend\ZendServer\share directory. Within this directory you will see, amongst others, 2 directories that are important; ZendFramework2 and ZendServerGateway.
  3. Copy these two directories to the vendor folder of your Web Services Project folder.
  4. Rename the ZendFramework2 folder to ZF2.
  5. Open the index.php file within the public directory of your Web Services Project folder. Find the following lines of code:

    Find:

    } elseif (is_dir(__DIR__ . ‘vendor/ZF2/library’)) {

    $zf2Path = __DIR__ . ‘vendor/ZF2/library’;

    }

Change to:

} elseif (is_dir(APPLICATION_PATH . ‘/vendor/ZF2/library’)) {

        $zf2Path = APPLICATION_PATH . ‘/vendor/ZF2/library’;

}

Find:

} elseif (is_dir(__DIR__ . ‘/vendor/ZendServerGateway’)) {

        $zsModsPath = __DIR__ . ‘/vendor/’;

}

Change to:

} elseif (is_dir(APPLICATION_PATH . ‘/vendor/ZendServerGateway’)) {

        $zsModsPath = APPLICATION_PATH . ‘/vendor/’;

}

  1. Now either open up a CMD/terminal window. Open the directory where your Web Services Project located. Enter the public directory and issue the following command:

php –S localhost:8080 (or whatever port you wish).

  1. Congratulations, your Web Services Project should now be running without using Zend Server 6!

Please note, I have not “hammered” this solution. Everything has worked as expected after the above changes to my environment; however, this doesn’t imply that this is a completely stable solution. So in summation, be careful before you use this solution in a production environment.

-Michael

About michaelandrewdavidson

I am a 30 year old Software Developer/Architect. I currently hold a Masters of Science in Computer Information Systems. I enjoy working with PHP and C#/.NET Framework. Currently I am on a drive to become cloud oriented in my development activities using the Microsoft Azure Cloud Platform.
This entry was posted in PHP, Programming and tagged , , , , , , , , , , . Bookmark the permalink.

3 Responses to Running ZendServerGateway on the embedded PHP 5.4 Server.

  1. Pingback: Running ZendServerGateway on the embedded PHP 5.4 Server – HackIX: Small Hacks for a Large World

  2. Jamie says:

    Hi Michael,
    First, thank you for the post. I am looking for a new approach to creating my mobile apps, and I have been looking at Zend Studio and its ‘solution’ for the Rest services. However, I am not sure of the costs if running my production on Zend Server clouds like rightscale and so on. I use Webfaction, which does not use Zend Server. I think I will try to see if I can also deploy to a regular LAMP server.

    It seems so hard to find Zend info that comes form regular people, not Zend company info… I guess they are so big the google searches always hot them. I was so glad to find your info 🙂

    OK, I read your bio and I am also a programmer who went thru cancer, Mine was over 4 years ago and was a rare tumor of the jaw and was supposed to not be cancer. Of course, after a 12 hour operation, they did test and it ended up having cancer cells. Anyway, I ended up with radiation treatments and chemo, and I am clear. The whole physical thing was liek getting hit by a bus over and over – it really ran me down. All during this, I am a Computer Engineer, head of a government IT team, and a father/husband. After about 6 months of sitting and watching the world, I finally started a programming project just to see if I could still think. Like programming in a fog 🙂 Anyway, it wasn’t until I went to an integrated medicine center at my Cancer hospital (Moffitt) that I got guidance there to start seeing an acupuncturist. That REALLY helped me. I was going like every week for a year, and I still go a couple times a month. It did tangible healing to the various systems that were wrecked in the whole treatment/post treatment phase.

    I tell you all this to encourage you to do your research and stay on top of things, but also to be open to meds outside the mainstream western medicine. As a Computer Engineer, I actually decided at the beginning to NOT try to figure out the logic behind Chinese Medicine and Acupuncture. I just started feeling better and stronger, and I can tell it works. I have seen 2 practitioners, both top notch people… and I think it matters if you find someone like that.

    Anyway, you are an important person in this world… and you WILL make it thru this whole. Give yourself time and work on the mental and spiritual side, as the doctors are working on eradicating the Cancer.

    Email me if you ever need a positive support boost my friend! You are not alone.
    Peace,
    Jamie

Leave a comment