1

I started with PHP a little while ago. I've been doing a lot of tutorials, practice sites, etc. and it's going great.

One thing I like about PHP is how easy it is to get started (downloading WAMP and voila). However, up until I learned about PEAR and MVC frameworks, I haven't put much thought in using a command line Interface for PHP development...

I've not really used the command line that much and it will take me some getting used to, so a couple of questions I have are:

What are the most common uses of the Command Line when developing websites and web applications with PHP?

Can you run MVC frameworks such as Zend, CakePHP, etc without ever using it?

Besides PEAR, are there any other PHP repositories that use the command line to work?

(It seems if you want to avoid using PEAR there are countless other PHP Classes/libraries on the internet that one could download and then simply copy and paste files into your site.)

Dynamic
  • 5,786
kdub
  • 119
  • 4

3 Answers3

4
  • background processing (yep, it's quite ugly)

    <?php system("php background-process.php &");

  • putting php jobs (e.g. db maintenance?) into cron tables

  • cgi processing in unsupported web servers
  • linting before uploading

    php -l file.php

  • fast checkup of daring language constructs

    php.exe -r "$a=array(1,6,9); array_splice($a,2,1,array(9,10,46)); var_export($a);"

    php -r '$a=array(1,6,9); array_splice($a,2,1,array(9,10,46)); var_export($a);'

  • testing backend code during development

...and then, I also do shell scripting in php.

#!/usr/bin/env php
<?php
  echo "Hello World!\n";
ZJR
  • 6,361
0

PHP is generally best suited to web development even though it has been adapted for other purposes. Common use on the command line is likely to be in the context of web development, particularly working with tools that are bundled with web frameworks such as the CakePHP console.

-1
  1. What are the most common uses of the Command Line when developing websites and web applications with PHP?

    Some. When you want to develop a web service that doesn't necessarily need an interface, like an auto response system to sms/emails, I would recommend writing an application that runs on the console. These are background processes generally.

  2. Can you run MVC frameworks such as Zend, CakePHP, etc without ever using it? From a Zend perspective: you can run the Zend framework without the console. The console only makes work a little easier, reduces repetition.

iglen_
  • 101