Create basic CodeIgniter project


/ Published in: Bash
Save to your folder(s)

/!\Notice: Change the ci_dir to wherever your ci folder is on line 3. /!\

Usage: ci [name of project]

Gives the project a name based on the current date if the user didn't provide one. Option to move the app directory outside of the system directory.

Edit [Sept 19, 2009]: I updated the script so that it also gives the option to create a public folder in the application root - that is in the same folder as the system folder. The script also create a css and a js folder in the public folder.


Copy this code and paste it in your HTML
  1. #!/bin/bash
  2. # This is where the CodeIgniter main folder is
  3. ci_dir="/Users/aziz/Sites/source/CodeIgniter_1.7.2"
  4.  
  5. # The current date used for the default project name if no project name is submited
  6. date=`date +"%Y-%m-%d_%H-%M-%S"`
  7.  
  8. # Create the main project folder
  9. if [ -z $1 ]
  10. then
  11. read -p "Choose a name for your project: [Default: ci-$date]" project_name
  12. if [ -z $project_name ]
  13. then
  14. \cp -R $ci_dir ./ci-$date
  15. project_name=ci-$date
  16. else
  17. \cp -R $ci_dir ./$project_name
  18. project_name=$project_name
  19. fi
  20. else
  21. let "folder_exists= 1"
  22. while [ $folder_exists -eq 1 ]
  23. do
  24. if [ -d $1 ]
  25. then
  26. echo 'This directory already exists'
  27. read -p "Choose a name for your project: [Default: ci-$date]" project_name
  28. if [ -z $project_name ]
  29. then
  30. let "folder_exists= 0"
  31. \cp -R $ci_dir ./ci-$date
  32. project_name=ci-$date
  33. else
  34. if [ -d $project_name ]
  35. then
  36. let "folder_exists= 1"
  37. else
  38. let "folder_exists= 0"
  39. \cp -R $ci_dir ./$project_name
  40. project_name=$project_name
  41. fi
  42. fi
  43. else
  44. let "folder_exists= 0"
  45. \cp -R $ci_dir $1
  46. project_name=$1
  47. fi
  48. done
  49. fi
  50.  
  51. # Ask the user if he wants to move the application folder outside the system folder
  52. dir=`pwd`
  53. echo "Project folder created in $dir/"
  54. read -p "Do you want to move the application? [Default: y]"$'\n'"[y/n] " -n 1 choice
  55. if [ -z $choice ] || [ $choice = 'y' ]
  56. then
  57. \cd "$project_name"
  58. mv system/application application
  59. \cd -
  60. echo -e "\nApplication folder moved outside the system folder\n"
  61. fi
  62. read -p "Do you want to create a public folder in the application root? [Default: y]"$'\n'"[y/n] " -n 1 choice
  63. if [ -z $choice ] || [ $choice = 'y' ]
  64. then
  65. \cd "$project_name"
  66. \mkdir -p public/css public/js
  67. \cd -
  68. echo -e "\nplublic folder successfully generated"
  69. fi
  70. echo -e "\nProject generated successfully in $dir/$project_name"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.