Path

ez.no / ezpublish / documentation / development / kernel / executing php shell scripts


Executing PHP shell scripts

These documentation pages are no longer maintained. Please visit the new documentation site.

Execution

It's possible to use PHP for shell scripting, however the placement of the PHP binary file are sometimes placed in non-standard directories, so assuming a path generally won't work.

#!/usr/bin/php

And you can't do without a path either since the path to the program must be specified for shell scripts.

#!php

The solution is to use the env program to execute the php binary. You do that by adding this to the top of the php script.

#!/usr/bin/env php

Executing the script is then done by

./myscript.php

Reading input

Reading input entered from the shell is possible trough the $argv variable. It will be an array with all the input parameters. The first entry in the array (index 0) is always the path to the script, or rather how the script was executed.

Example for help detection

foreach ( $argv as $argument )

{

   if ( $argument == '-h' )

       print( "Usage: " . $argv[0] . " -h" );

}

Comments

Contents

Development

Extensions
eZ publish datamodel
eZ publish tuning and stability
Importing attribute data
Kernel
    Executing PHP shell scripts
    eZ SOAP Web Services Overview
    Deploying SOAP Servers with eZ Publis...
    Custom template operators
    Cache block optimization
Libraries
Scripting
Standards
System overview
Test Suite
Using Doxygen to create API documenta...


Created

03/04/2003
12:43:48 pm
by Jan Borsodi

Last updated

04/07/2003
3:40:50 pm
by Bård Farstad

Authors

Jan Borsodi
Bård Farstad



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.