Using PHP within the Expression Development ServerAuthor: Chris Leeds, Microsoft MVP Web Site:
http://ExpressionWebStepByStep.com Expression Newsletter,
subscribe now to get yours. About the Author: Chris Leeds is a long-time Microsoft MVP and the author of two Microsoft Press books about Expression Web (
http://ExpressionWebStepByStep.com). Besides writing about and using Expression Web, Chris is also the inventor of ContentSeed (
http://ContentSeed.com) a very simple Content Management System that enables end users to be able to edit content on their web site with nothing more than a browser. One of the best features that Expression Web brings you is the Expression Development Server. This tool saves the designer from having to set up a local server on their computer to test dynamic pages such as PHP and ASP.NET. For a designer without a local server, the only way to test and view these dynamic pages (pages with Server-Side Scripting) is to publish them to a server elsewhere, and then view them in a browser, which after a short time becomes cumbersome and slows the design/development process down too much to be practical. When you preview an ASP.NET page from within Expression Web by clicking the “Preview in a browser” button, the Expression Web Development Server processes the ASP.NET code within the page and passes the resulting HTML and CSS to the browser automatically. This is especially useful if the designer is using the ASP.NET Master Pages feature for a site template or using any of the ASP.NET Navigation Controls, and other server-side controls that render HTML to the browser. The inherent ability to deal with ASP.NET pages isn’t present for PHP, but in just a few steps you can run PHP files within Expression Web as easily as you can ASP.NET file. - Go to
http://windows.php.net/download/ and download the latest version in the Windows Installer.
You could download the .ZIP files, but the whole pretext of this article is to set up PHP for the Development Server the easiest way possible.
.jpg) - Run the PHP installer and choose “Other .CGI” as the installation type.
You can leave all other defaults as they are. .jpg)
- Using Windows Explorer, browse to the installation folder, which will be something like: C:/Program Files/PHP. Right click the PHP folder and then click Properties. The Properties dialog opens.
- Click the Security tab and then click Edit. Give full permission to the Users group by clicking each unmarked checkbox, and then click OK.
.jpg) The reason for this extra step is that Expression Web will attempt to edit the PHP .INI file to its own specifications. If the permissions aren’t appropriate, it won’t work, so taking this step now makes the next few steps much easier. - Close Windows Explorer and open Expression Web. If a site opens within Expression Web, click Site > Close.
- Click Tools > Application Options. In the PHP section at the bottom of the General tab, click Browse. Browse to the PHP directory that you set permissions for in the previous step and select the php-cgi.exe file and then click OK on the Application Options dialog.
.jpg)
- Click File > New > PHP. Expression Web creates a new PHP file.
- Set your cursor inside of the Code Pane between the body tags and enter:
<?php (phpinfo()) ?>
.jpg) - Click the Save button and save the page, then click Preview in a Browser. Expression Web will open a dialog about changing the .INI file. Click OK.
- Your page opens in a browser and shows the PHP information.
.jpg)
That’s it; you’re running PHP in the Expression Development Server. You can now use and view PHP Includes, functions, and variables. In most cases you’ll be able to do run PHP files without the extra work of setting up a full version of a local server. For a screen video of this process, see:
http://ExpressionWebStepByStep.com/Resources?content=PHP-EDS
|