Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 6. Going Offline > Creating a Dynamic Manifest File

6.3. Creating a Dynamic Manifest File

Now that we’re comfortable with how the offline app cache works, let’s apply it to the Kilo example we’ve been working on. Kilo consists of quite a few files, and manually listing them all in a manifest file would be a pain. Moreover, a single typo would invalidate the entire manifest file and prevent the application from working offline.

Running PHP Scripts on Your Web Server

PHP is a versatile web scripting language and is supported by most web hosting providers. This means that on most web servers, you can create a file whose name ends with the extension .php, add some PHP code to it, visit it in your web browser, and it will just work. If you’ve been using a web server on your personal computer to serve up pages to your iPhone, you’ll need to get set up to run PHP scripts. If you’re running a web server on Windows, see http://php.net/manual/en/install.windows.php for downloads and information. PHP is easy to install on Linux (for example, Ubuntu users can simply type sudo aptitude install apache2 php5 at a shell prompt).

Macs come with PHP installed, but you need to take a step to enable it. Similar to what you did in Mac OS X and the .htaccess File, open ApplicationsUtilitiesTerminal and type these commands (you’ll need to type your password when prompted):

cd /etc/apache2
sudo pico httpd.conf

Next, press Control-W. This brings up the option to search the file. Type “php5” and then press Return. This brings you to a line that should look like this:

#LoadModule php5_module        libexec/apache2/libphp5.so

Using the arrow keys, move to the beginning of the line and delete the # comment character, which is preventing this line from having any effect. Then press Control-X to exit, answer Y to save changes, and then press Return to save the file. Next, start System Preferences, go to Sharing, and, if needed, click the lock icon labeled “Click the lock to make changes” and type your password when prompted. Then, clear the checkbox next to Web Sharing and check it again. Now PHP should be enabled on your Mac’s web server.

Next, create a file in the Sites subdirectory of your home folder named test.php with these contents:

<?php 
  phpinfo(); 
?>

Finally, visit the following URL in your browser: http://localhost/~YOURUSERNAME/test.php. Replace YOURUSERNAME with your username, but don’t delete the ~. (You can find out your username at the Terminal by typing echo $USER and pressing Return.) If PHP is working, you’ll see a table displaying your PHP version number and a lot of other information about your PHP installation. If it is not working, you’ll see nothing but a blank page. Visit http://www.php.net/support.php for links to sources of documentation and help with using PHP.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint