background preloader

Create daemons in PHP

Create daemons in PHP
Everyone knows PHP can be used to create websites. But it can also be used to create desktop applications and commandline tools. And now with a class called System_Daemon, you can even create daemons using nothing but PHP. And did I mention it was easy? Update 4 Dec, 2012: Legacy Warning This class was relevant in 2009, and may still be to some people, but if you want to daemonize a php script nowadays, a 5-line Ubuntu upstart script should suffice. If you're still convinced you need to do this with pure PHP, read on. What is a Daemon? A daemon is a Linux program that run in the background, just like a 'Service' on Windows. You reading this page, would not have been possible without them. Why PHP? Most daemons are written in C. Reuse & connect existing code Think of database connections, classes that create customers from your CRM, etc.Deliver new applications very fast PHP has a lot of build in functions that speed up development greatly.Everyone knows PHP (right?) Possible use cases Beta

PHP for Beginners: Building Your First Simple CMS The Magic of PHP + MySQL It’s safe to say that nearly every website that’s up-to-date these days is using some form of content management system (CMS). While there are a ton of great free options that provide us with a CMS to power a website (WordPress, Drupal, etc.), it doesn’t hurt to peek under the hood and get a feel for how these systems work. To get our feet wet as back-end developers, we’ll be creating a simple PHP class that will: Create a databaseConnect to a databaseDisplay a form with two fieldsSave the form data in the databaseDisplay the saved data from the database Download Files This class is intended to give you a feel for how PHP and MySQL interact together, and to show the basics of a CMS. Building the Class Our first step is to simply lay out the class in a file named ‘simpleCMS.php’ so we have a road map to work with. As you can see, we’re creating one class with four variables and five methods. The Variables Build the Database Connect to the Database Build the Form <! <?

Posts PHPBuilder.com, the best resource for PHP tutorials, templates, PHP manuals, content management systems, scripts, classes and more. I wish I had known these 10 tips the day I started working with PHP. Instead of learning them through painstaking process, I could have been on my way to becoming a PHP programmer even sooner! This article is presented in two parts and is intended for folks who are new to PHP. Tip 1: MySQL Connection Class The majority of web applications I've worked with over the past year have used some variation of this connection class: class DB { function DB() { $this->host = "localhost"; // your host $this->db = "myDatabase"; // your database $this->user = "root"; // your username $this->pass = "mysql"; // your password $this->link = mysql_connect($this->host, $this->user, $this->pass); mysql_select_db($this->db); } } // calls it to action $db = new $DB; Simply edit the variables and include this in your files. $result = mysql_query("SELECT * FROM table ORDER BY id ASC LIMIT 0,10"); More information can be found in the manual--be sure you read the comments:

Create a Windows 7 Live CD [How To] | Maintenance and System Tools About a year ago I set out to create me a Windows 7 live CD. Finally, I am able to present you with the How-To. But before we get into that, let’s review what a LIVE CD is. A Live CD is an actual Windows Installation that you carry with you on a USB Flash Drive or CD/DVD. The Windows Installation is portable, meaning that you can have your own windows running on any PC you encounter. The Live CDs are most commonly used to repair computers that have crashed or to rescue data from a hard drive before doing a fresh installation. In the Linux World it has been around for years ( and as Windows XP). Enough chit chat, let’s get on with it… The overview In order to create a Live CD from Windows 7, we need to download a utility called WinBuilder (download link at the end of this article). NOTE! Upon first launch, WinBuilder will open the Download Script Page, which allows you to browse through lots of available projects. Running the scripts NOTE! Making it easy Downloads NOTE! Useful Links About Thomas

Easy PHP Blackhole Trap with WHOIS Lookup for Bad Bots One of my favorite security measures here at Perishable Press is the site’s virtual Blackhole trap for bad bots. The concept is simple: include a hidden link to a robots.txt-forbidden directory somewhere on your pages. Bots that ignore or disobey your robots rules will crawl the link and fall into the trap, which then performs a WHOIS Lookup and records the event in the blackhole data file. Once added to the blacklist data file, bad bots immediately are denied access to your site. I call it the “one-strike” rule: bots have one chance to follow the robots.txt protocol, check the site’s robots.txt file, and obey its directives. Failure to comply results in immediate banishment. In five easy steps, you can set up your own Blackhole to trap bad bots and protect your site from evil scripts, bandwidth thieves, content scrapers, spammers, and other malicious behavior. The Blackhole is built with PHP, and uses a bit of .htaccess to protect the blackhole directory. Installation Overview

How To Make Your Own Windows Live CD Live CDs as you know allow you to boot your computer from a CD-ROM and performs various functions on your system. Such Live CDs are excellent for recovering data, fixing problems or to have a custom desktop at your disposal when you are not at your own computer. While the Live CDs are common place in the Linux world, it’s not often that you hear about a Windows Live CD. Here today we are going to show you how to make custom Windows Live CD Tools Required Bart PEYour Windows installation CD Steps Download and install the latest version of Bart PE. All additional functionality that you want to add is done by means of plug-ins. Click ‘add’ and browse to the location where you stored the Windows XPE plug-in to add it. If the build process completes without any errors, you have made yourself a Live CD. Mine completed in just under 2 minutes without any errors and amounted to 270 MB with Windows XPE plug-in and 154 MB without it. Have you ever created a custom Live CD?

OBJECT ORIENTED PHP TUTORIAL FOR BEGINNERS Preamble The hardest thing to learn (and teach btw,) in object oriented PHP is the basics. But once you understand them, the rest will come much, much easier. But don’t be discouraged! … Or so I’ve been told. About This Tutorial This tutorial is designed to teach total beginners object oriented PHP. This is not a long-winded theoretical blathering that you see all too often; instead, we actually start writing OO code very quickly. So before you begin, get out your favorite PHP code editor and be ready to write and run some object oriented PHP code. PS: scroll to the bottom of the page for the supporting videos. Thanks for reading, Stefan Mischook Introduction With the release of php5 in 2004, php programmers finally had the power to code with the ‘big boys’. In this tutorial, you will be guided (step-by-step) through the process of building and working with objects using php’s built-in OOP capabilities. OOP Videos

New cool list of Windows must have programs Updated: October 17, 2009 Welcome back to another must-have article. Today, I'm going to present a long list of superb Windows programs that should be an inseparable part of your arsenal. Introduction This article continues the legacy of its two-year old predecessor, the more recently published A-Z guide, which lists 26 best Windows programs for 2009, one application per letter, and the new Linux cool list, which, although oriented for the Linux operating system, contains a large number of cross-platform solutions also available for Windows. I sincerely hope you will enjoy this article, as it offers a wealth of useful information of free, robust, stable, productive software that will enhance the quality, efficiency and fun of your work in the Windows environment. Some small reservations ... Since these articles overlap rather heavily and yet each presents a different set of unique tools, your best bet is to start poring through slowly and compile what you find best for your needs. Blender

Improve website load time by 500% with 3 lines of code | Aciddrop.com Major New Update - PHP SPEEDY: latest version available here There are 4 relatively easy ways by which you can speed up the time it takes a browser to download a page: Make fewer HTTP requestsAdd a far-future expires headerGzip your page's componentsMinify your JavaScript, CSS and HTML Following on from my post on joining CSS and JavaScript files, I have written a PHP script which will automatically do all of the above. All you have to do is call the following at the top of your page: The code require_once('class.compressor.php'); //Include the class. And the following at the bottom of the page: The Demo That's it! The class can be downloaded here: site speed boost class download Requirements A server running at least PHP4. Setting basic options Options can be set with a comma separated string as follows: $compressor = new compressor('css,javascript,page'); The string can contain 'css', 'javascript' and 'page' depending on which elements you would like to be compressed. Setting advanced options

Web hosting, dedicated hosting, VPS hosting, webhosting by DreamHost Good PHP Tutorials - Beginner To Advanced PHP Programming Tutorials A Comparison of Methods for Building Mobile-Optimized Websites There’s a debate over which technique of creating mobile-ready websites is the best. Google advocates creating responsive web designs, while Jakob Nielsen, a renowned usability consultant, endorses the creation of dedicated mobile sites (but he was subsequently slammed by some web designers). A third option is also gaining in popularity, where the web server renders the appropriate HTML and CSS from the same URL depending on the device a web page on the site is being requested from (which has been referred to as responsive design + server side components). This article will discuss each of these methods. Real-world examples of websites using a particular method are provided under each section. The mobile device used to test and gather data for all examples is an iPhone 4 using iOS 5.0. Responsive Web Design (RWD) Responsive web design (RWD) typically uses CSS3 media queries to adjust the layout of a web page based on the size of the user’s viewing area. Advantages of Responsive Web Design eHow

Related: