Skip to main content

Posts

Can I run a PHP script on cron?

Yes, you can run a PHP script on cron. Look here to see how to setup your own crontab. If your PHP scripts do not have executable permissions, 644 or -rw-r--r-- for example, then as part of the command portion of the cron line, you must specify the php interpreter and pass it the filename of the PHP script (including full path to the script from your home directory) that you want executed, like so: 28 14 * * * /usr/local/bin/php -q /myscript.phtml 6 3 20 4 * /usr/local/bin/php -q /htdocs/www/x.php The first cron line above will run myscript.phtml located in your home directory every day at 2:28PM. The second line will run the script x.php from your /htdocs/www/ directory once a year on April 20th at 3:06AM. When you explicitly specify the php interpreter /usr/local/bin/php your scripts need not have filenames ending in .php .phtml .php3 .php4. Conversely, if your script filenames do not end in one of those PHP extensions, then you must explicitly use the php interpreter in the command ...

Eclipse - an open development platform

Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A large and vibrant ecosystem of major technology vendors, innovative start-ups, universities, research institutions and individuals extend, complement and support the Eclipse platform. New to Eclipse? Enterprise Development Embedded + Device Development Equinox Runtimes Application Frameworks Language IDE

Writing Scalable Applications with PHP

The first part of this article, "Real-World PHP Security", appeared in the April 2004 issue of Linux Journal and covered the subject of secure PHP development. This article takes you, the professional PHP developer, one step further, by providing detailed explanations and reliable source code that illustrate the steps to follow in order to develop successful PHP applications. One day or another, every developer faces a situation in which he/she is responsible for extending the functionality of an existing application or prepare an application for an increase in use and traffic (scaling up). Our goal today is to make this process trivial by learning to develop applications based on a clean, elegant and modular design that is secure, reliable and flexible while keeping it all simple. Please refer to Figure 1, previously introduced in "Real World PHP Security" and included below. Figure 1. Our Application Model Diagram Cleaning Up the Operating Environment As a...

Running PHP Scripts with Cron

Lots of programmers like PHP for its ability to code and develop web applications fast. Code-debugging is a lot easier than with PERL or C. However, there is one thing a lot of developers are puzzled about, “How to run PHP Scripts with crontab?” Cron is normally available on all Unix and Linux distributions; if you cannot access it, contact your root or server administrator. It is a daemon which allows you to schedule a program or script for a specific time of execution. If you want to learn more about cron, click here or type “man crontab” at your command prompt. I have found myself in the need to run PHP scripts at specific times. For example, to update the content of a website, to remove expired articles, to send out e-mails on a given date and a lot more. While some may think that this is were PHP is doomed, I will show you how it’s done. A Manual crontab? The first solution that came to my mind was to run the script directly from my browser (e.g. http://www.mydomain.com/script.php...

Caching PHP Programs with PEAR

Contents: Caching in context Where to get PEAR Cache How PEAR Cache works Function call caching Output caching Customized solutions style="font-size:85%;"> Caching in context Caching is currently a hot topic in the PHP world. Because PHP produces dynamic web pages, scripts must be run and results must be calculated each time a web page is requested, regardless if the results are the same each time. In addition, PHP compiles the script every time it is requested. This overhead can seriously slow down a site with heavy traffic. Fortunately, the results of a web request can be stored, or cached, and presented to matching requests without having to re-run or recompile the scripts. Commercial products like ZendCache or open-source solutions such as Alternate PHP Cache provide a means to cache the compiled version of a PHP script -- the byte-code. While these "PHP land" solutions scratch an itch in PHP's design, "Userland" solutions can go a step...

LAMP development with XAMPP

If you have ever had to set up a Linux, Apache, MySQL and PHP or Perl installed and running at the same time you know what hassle it can be. If you are new Linux it can be a rather daunting experience just trying to set everything up, nevermind learning scripting languages like PHP, Perl and a database like MySQL or SQL Lite. XAMPP is a single packaged download from Apache Friends which provides all of the pieces of software needed, plus more you probably don't need, to make Apache installations with server-side scripting and a few database options ready to go in a testing or development environment. In this article we will focus on getting XAMPP running on Linux, it will also work on Windows and a version for Sun’s Solaris is also available. For our example we will use a Debian-based Linux distribution, but just about any flavour of Linux will work. To start, you will need to download the XAMPP package for Linux from the SourceForge Web site . The XAMPP includes the following so...

Lets Shindig

Following the introductory presentation on OpenSocial at the Google Developer Day conference in Sydney, Dan Peterson and John Hjelmstad delved into the workings of Shindig with their presentation "Apache Shindig: Make your social site an OpenSocial container". What is Shindig? Shindig, a project in Apache Software Foundation Incubation is an open source implementation of OpenSocial and gadgets. At present Shindig provides two ports, one in Java and one in PHP, both of which support version 0.7 of OpenSocial. There is work in progress for version 0.8 which will introduce the RESTful API. Some containers using the Java version of Shindig are hi5, iGoogle and orkut. There is a strong open source community behind Shindig, producing some high quality code, with updates occurring as OpenSocial evolves. Shindig Architecture Dan and John showed a diagram similar to the one below to illustrate the structure of Shindig. It is made up of three main components. |> Gadge...