generate php classes in bash

Posted by Derek on Stack Overflow See other posts from Stack Overflow or by Derek
Published on 2011-11-18T17:01:49Z Indexed on 2011/11/18 17:50 UTC
Read the original article Hit count: 169

Filed under:
|

i have this script:

  #!/bin/bash

  if [[ -z "$1" ]] ; then
      echo "Class is required"
      exit 1;
  fi

  if [[ -z "$2" ]] ; then
      package="Default"
  else
      package=$2;
  fi

  echo "<?php
  /**
   * $1.class.php
   * 
   * Vcard class file.
   * @name        Project
   * @author      Author
   * @link        http://www.domain.com
   * @copyright   Copyright © 2011
   * @package     $package
   * @version     1.0
  */

  /**
   * The main $1 class
   * @package $package
  */
  class $1 {

      /**
       * Constructor setup.
       */
      public function __construct() {
      }

      /**
       * Destructor setup.
       */
      public function __destruct() {
      }
  }
  " > $1.class.php

  php -l $1.class.php
  echo "Done";

if i do:

./generate.sh my_class it creates everything with my_class. how can i modify this to: MyClass?

i need to use MyClass for the filename, and the class name etc... later in the code i use the argument (in this case my_class) for some other purposes.

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about bash