Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

HowTo: Administer Your System with PHP

DZone's Guide to

HowTo: Administer Your System with PHP

· Web Dev Zone
Free Resource

Never build auth again! Okta makes it simple to implement authentication, authorization, MFA and more in minutes. Try the free developer API today! 

Many web developers would love to do everything in PHP -- maybe because it was their first web programming language, or because plenty of pre-written code is available online; or maybe just because PHP is actually quite fast.

When the PHP engine is being called by a web server, there's one thing you can't easily do with PHP: administer your system.

But, as this post from the Winning Web Works blog points out, it's actually pretty easy to use PHP 4.2.0 and above for lots of server-related tasks.

The reason? PHP 4.2.0 (and above) can be invoked directly from the command line.

Short version:

Although many have attempted to use PHP as the “golden hammer” in the past, this strategy often proves highly inconvenient simply because server-based tasks were simply never meant to run over extended periods of time. However, as of PHP version 4.2.0, it’s possible to directly invoke the PHP engine by calling it from the operating system command-line, available via a new SAPI type known as the CLI (Command Line Interface). This new capability opens up the possibility for system administrators to use PHP for managing various server-related tasks, among which include duties pertinent to managing system backups, monitoring system resources, and parsing logs. 

The full post shows you how to make sure your system is configured to handle command-line PHP, offers a simple example (timezone adjustment calculator), and answers a few likely questions you might have. No real-world sysadmin example scripts just yet, but (the post promises) those are coming.

If you're super-comfortable with PHP, and would like to stretch your PHP beyond web programming, then the article is a good read.

Launch your application faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}