こんにちは。rubyが好きですが、業務でPHPを書くことになり、まずは業務をこなせることを見せようと思っているkikeda1104です。このタイトルで書くのもあれですが、Rubyのコミニティに貢献できるようになりたいですねぇ。
で、codeigniter2.2というフレームワークをプロジェクトで利用していますが、フレームワークそのものにバグがあったり、日本語のドキュメントの更新がとまっていたり、仕様がややおかしいなと思えるフレームワークです。(あんまり好ましく思っていないです。)
後ほど説明しますが、学習コストが低いことが利点としてあげられていますが、学習コストが0になるわけではなく、それなりにはかかるので、プロジェクトの立ち上げ時にはフレームワークの知識の習得や慣れも見積もりに入れるべきだと思います。(参加プロジェクトでも、当初から伝えていますし、遅れていても、自分を責めるつもりはありません。(何)
とはいえ、プロジェクトに参加される方に迷惑をかけたくはないので、できる限り時間を投資していきたい。自社サービスの際にはチームになりますしね。まぁ、余談です。
それで本題です。
デザイナーの方に(HTML+CSSをコーディングしていただける方)に環境設定のお手伝いをする機会があったので、 備忘録として書いておきます。
codeigniterとは
PHPで書かれているwebアプリケーションフレームワークです。特徴としてあげているのが、学習コストが低い。つまり、構成やDSLが単純であることが売りのようです。2011年で日本語のサイトの更新が止まっていますが、当時世界的にもシェアが高かったようです。
公式ホームページ
- 日本語公式ページ
- 日本語のユーザドキュメント
CodeIgniterへようこそ : CodeIgniter ユーザガイド 日本語版
日本語のドキュメントは古いので、海外の公式を参考にするようにしましょう。
環境構築
環境構築は簡単で、codeigniterをダウンロードすることで利用できます。
http://www.codeigniter.com/downloadからダウンロードして解凍します。
$ wget https://github.com/bcit-ci/CodeIgniter/archive/2.2-stable.zip $ unzip 2.2-stable.zip
ディレクトリ構成は以下のようですね。
$ CodeIgniter-2.2-stable
.
├── application
│ ├── cache
│ │ └── index.html
│ ├── config
│ │ ├── autoload.php
│ │ ├── config.php
│ │ ├── constants.php
│ │ ├── database.php
│ │ ├── doctypes.php
│ │ ├── foreign_chars.php
│ │ ├── hooks.php
│ │ ├── index.html
│ │ ├── migration.php
│ │ ├── mimes.php
│ │ ├── profiler.php
│ │ ├── routes.php
│ │ ├── smileys.php
│ │ └── user_agents.php
│ ├── controllers
│ │ ├── index.html
│ │ └── welcome.php
│ ├── core
│ │ └── index.html
│ ├── errors
│ │ ├── error_404.php
│ │ ├── error_db.php
│ │ ├── error_general.php
│ │ ├── error_php.php
│ │ └── index.html
│ ├── helpers
│ │ └── index.html
│ ├── hooks
│ │ └── index.html
│ ├── index.html
│ ├── language
│ │ ├── english
│ │ │ └── index.html
│ │ └── index.html
│ ├── libraries
│ │ └── index.html
│ ├── logs
│ │ └── index.html
│ ├── models
│ │ └── index.html
│ ├── third_party
│ │ └── index.html
│ └── views
│ ├── index.html
│ └── welcome_message.php
├── index.php
├── license.txt
├── system
│ ├── core
│ │ ├── Benchmark.php
│ │ ├── CodeIgniter.php
│ │ ├── Common.php
│ │ ├── Config.php
│ │ ├── Controller.php
│ │ ├── Exceptions.php
│ │ ├── Hooks.php
│ │ ├── index.html
│ │ ├── Input.php
│ │ ├── Lang.php
│ │ ├── Loader.php
│ │ ├── Model.php
│ │ ├── Output.php
│ │ ├── Router.php
│ │ ├── Security.php
│ │ ├── URI.php
│ │ └── Utf8.php
│ ├── database
│ │ ├── DB_active_rec.php
│ │ ├── DB_cache.php
│ │ ├── DB_driver.php
│ │ ├── DB_forge.php
│ │ ├── DB.php
│ │ ├── DB_result.php
│ │ ├── DB_utility.php
│ │ ├── drivers
│ │ │ ├── cubrid
│ │ │ │ ├── cubrid_driver.php
│ │ │ │ ├── cubrid_forge.php
│ │ │ │ ├── cubrid_result.php
│ │ │ │ ├── cubrid_utility.php
│ │ │ │ └── index.html
│ │ │ ├── index.html
│ │ │ ├── mssql
│ │ │ │ ├── index.html
│ │ │ │ ├── mssql_driver.php
│ │ │ │ ├── mssql_forge.php
│ │ │ │ ├── mssql_result.php
│ │ │ │ └── mssql_utility.php
│ │ │ ├── mysql
│ │ │ │ ├── index.html
│ │ │ │ ├── mysql_driver.php
│ │ │ │ ├── mysql_forge.php
│ │ │ │ ├── mysql_result.php
│ │ │ │ └── mysql_utility.php
│ │ │ ├── mysqli
│ │ │ │ ├── index.html
│ │ │ │ ├── mysqli_driver.php
│ │ │ │ ├── mysqli_forge.php
│ │ │ │ ├── mysqli_result.php
│ │ │ │ └── mysqli_utility.php
│ │ │ ├── oci8
│ │ │ │ ├── index.html
│ │ │ │ ├── oci8_driver.php
│ │ │ │ ├── oci8_forge.php
│ │ │ │ ├── oci8_result.php
│ │ │ │ └── oci8_utility.php
│ │ │ ├── odbc
│ │ │ │ ├── index.html
│ │ │ │ ├── odbc_driver.php
│ │ │ │ ├── odbc_forge.php
│ │ │ │ ├── odbc_result.php
│ │ │ │ └── odbc_utility.php
│ │ │ ├── pdo
│ │ │ │ ├── index.html
│ │ │ │ ├── pdo_driver.php
│ │ │ │ ├── pdo_forge.php
│ │ │ │ ├── pdo_result.php
│ │ │ │ └── pdo_utility.php
│ │ │ ├── postgre
│ │ │ │ ├── index.html
│ │ │ │ ├── postgre_driver.php
│ │ │ │ ├── postgre_forge.php
│ │ │ │ ├── postgre_result.php
│ │ │ │ └── postgre_utility.php
│ │ │ ├── sqlite
│ │ │ │ ├── index.html
│ │ │ │ ├── sqlite_driver.php
│ │ │ │ ├── sqlite_forge.php
│ │ │ │ ├── sqlite_result.php
│ │ │ │ └── sqlite_utility.php
│ │ │ └── sqlsrv
│ │ │ ├── index.html
│ │ │ ├── sqlsrv_driver.php
│ │ │ ├── sqlsrv_forge.php
│ │ │ ├── sqlsrv_result.php
│ │ │ └── sqlsrv_utility.php
│ │ └── index.html
│ ├── fonts
│ │ ├── index.html
│ │ └── texb.ttf
│ ├── helpers
│ │ ├── array_helper.php
│ │ ├── captcha_helper.php
│ │ ├── cookie_helper.php
│ │ ├── date_helper.php
│ │ ├── directory_helper.php
│ │ ├── download_helper.php
│ │ ├── email_helper.php
│ │ ├── file_helper.php
│ │ ├── form_helper.php
│ │ ├── html_helper.php
│ │ ├── index.html
│ │ ├── inflector_helper.php
│ │ ├── language_helper.php
│ │ ├── number_helper.php
│ │ ├── path_helper.php
│ │ ├── security_helper.php
│ │ ├── smiley_helper.php
│ │ ├── string_helper.php
│ │ ├── text_helper.php
│ │ ├── typography_helper.php
│ │ ├── url_helper.php
│ │ └── xml_helper.php
│ ├── index.html
│ ├── language
│ │ ├── english
│ │ │ ├── calendar_lang.php
│ │ │ ├── date_lang.php
│ │ │ ├── db_lang.php
│ │ │ ├── email_lang.php
│ │ │ ├── form_validation_lang.php
│ │ │ ├── ftp_lang.php
│ │ │ ├── imglib_lang.php
│ │ │ ├── index.html
│ │ │ ├── migration_lang.php
│ │ │ ├── number_lang.php
│ │ │ ├── profiler_lang.php
│ │ │ ├── unit_test_lang.php
│ │ │ └── upload_lang.php
│ │ └── index.html
│ └── libraries
│ ├── Cache
│ │ ├── Cache.php
│ │ ├── drivers
│ │ │ ├── Cache_apc.php
│ │ │ ├── Cache_dummy.php
│ │ │ ├── Cache_file.php
│ │ │ ├── Cache_memcached.php
│ │ │ └── index.html
│ │ └── index.html
│ ├── Calendar.php
│ ├── Cart.php
│ ├── Driver.php
│ ├── Email.php
│ ├── Encrypt.php
│ ├── Form_validation.php
│ ├── Ftp.php
│ ├── Image_lib.php
│ ├── index.html
│ ├── javascript
│ │ ├── index.html
│ │ └── Jquery.php
│ ├── Javascript.php
│ ├── Log.php
│ ├── Migration.php
│ ├── Pagination.php
│ ├── Parser.php
│ ├── Profiler.php
│ ├── Session.php
│ ├── Sha1.php
│ ├── Table.php
│ ├── Trackback.php
│ ├── Typography.php
│ ├── Unit_test.php
│ ├── Upload.php
│ ├── User_agent.php
│ ├── Xmlrpc.php
│ ├── Xmlrpcs.php
│ └── Zip.php
└── user_guide
├── changelog.html
├── database
│ ├── active_record.html
│ ├── caching.html
│ ├── call_function.html
│ ├── configuration.html
│ ├── connecting.html
│ ├── examples.html
│ ├── fields.html
│ ├── forge.html
│ ├── helpers.html
│ ├── index.html
│ ├── queries.html
│ ├── results.html
│ ├── table_data.html
│ ├── transactions.html
│ └── utilities.html
├── doc_style
│ ├── index.html
│ └── template.html
├── general
│ ├── alternative_php.html
│ ├── ancillary_classes.html
│ ├── autoloader.html
│ ├── caching.html
│ ├── cli.html
│ ├── common_functions.html
│ ├── controllers.html
│ ├── core_classes.html
│ ├── creating_drivers.html
│ ├── creating_libraries.html
│ ├── credits.html
│ ├── drivers.html
│ ├── environments.html
│ ├── errors.html
│ ├── helpers.html
│ ├── hooks.html
│ ├── libraries.html
│ ├── managing_apps.html
│ ├── models.html
│ ├── profiling.html
│ ├── quick_reference.html
│ ├── requirements.html
│ ├── reserved_names.html
│ ├── routing.html
│ ├── security.html
│ ├── styleguide.html
│ ├── urls.html
│ └── views.html
├── helpers
│ ├── array_helper.html
│ ├── captcha_helper.html
│ ├── cookie_helper.html
│ ├── date_helper.html
│ ├── directory_helper.html
│ ├── download_helper.html
│ ├── email_helper.html
│ ├── file_helper.html
│ ├── form_helper.html
│ ├── html_helper.html
│ ├── inflector_helper.html
│ ├── language_helper.html
│ ├── number_helper.html
│ ├── path_helper.html
│ ├── security_helper.html
│ ├── smiley_helper.html
│ ├── string_helper.html
│ ├── text_helper.html
│ ├── typography_helper.html
│ ├── url_helper.html
│ └── xml_helper.html
├── images
│ ├── appflowchart.gif
│ ├── arrow.gif
│ ├── ci_logo_flame.jpg
│ ├── ci_logo.jpg
│ ├── ci_quick_ref.png
│ ├── codeigniter_1.7.1_helper_reference.pdf
│ ├── codeigniter_1.7.1_helper_reference.png
│ ├── codeigniter_1.7.1_library_reference.pdf
│ ├── codeigniter_1.7.1_library_reference.png
│ ├── file.gif
│ ├── folder.gif
│ ├── nav_bg_darker.jpg
│ ├── nav_separator_darker.jpg
│ ├── nav_toggle_darker.jpg
│ ├── reactor-bullet.png
│ ├── smile.gif
│ └── transparent.gif
├── index.html
├── installation
│ ├── downloads.html
│ ├── index.html
│ ├── troubleshooting.html
│ ├── upgrade_120.html
│ ├── upgrade_130.html
│ ├── upgrade_131.html
│ ├── upgrade_132.html
│ ├── upgrade_133.html
│ ├── upgrade_140.html
│ ├── upgrade_141.html
│ ├── upgrade_150.html
│ ├── upgrade_152.html
│ ├── upgrade_153.html
│ ├── upgrade_154.html
│ ├── upgrade_160.html
│ ├── upgrade_161.html
│ ├── upgrade_162.html
│ ├── upgrade_163.html
│ ├── upgrade_170.html
│ ├── upgrade_171.html
│ ├── upgrade_172.html
│ ├── upgrade_200.html
│ ├── upgrade_201.html
│ ├── upgrade_202.html
│ ├── upgrade_203.html
│ ├── upgrade_210.html
│ ├── upgrade_211.html
│ ├── upgrade_212.html
│ ├── upgrade_213.html
│ ├── upgrade_214.html
│ ├── upgrade_220.html
│ ├── upgrade_b11.html
│ └── upgrading.html
├── libraries
│ ├── benchmark.html
│ ├── caching.html
│ ├── calendar.html
│ ├── cart.html
│ ├── config.html
│ ├── email.html
│ ├── encryption.html
│ ├── file_uploading.html
│ ├── form_validation.html
│ ├── ftp.html
│ ├── image_lib.html
│ ├── input.html
│ ├── javascript.html
│ ├── language.html
│ ├── loader.html
│ ├── migration.html
│ ├── output.html
│ ├── pagination.html
│ ├── parser.html
│ ├── security.html
│ ├── sessions.html
│ ├── table.html
│ ├── trackback.html
│ ├── typography.html
│ ├── unit_testing.html
│ ├── uri.html
│ ├── user_agent.html
│ ├── xmlrpc.html
│ └── zip.html
├── license.html
├── nav
│ ├── hacks.txt
│ ├── moo.fx.js
│ ├── nav.js
│ ├── prototype.lite.js
│ └── user_guide_menu.js
├── overview
│ ├── appflow.html
│ ├── at_a_glance.html
│ ├── cheatsheets.html
│ ├── features.html
│ ├── getting_started.html
│ ├── goals.html
│ ├── index.html
│ └── mvc.html
├── toc.html
├── tutorial
│ ├── conclusion.html
│ ├── create_news_items.html
│ ├── hard_coded_pages.html
│ ├── index.html
│ ├── news_section.html
│ └── static_pages.html
└── userguide.css
48 directories, 355 files
config.php
$ vi config/config.php # base_urlを入力する $ config['base_url'] = 'http://localhost:3000';
apacheの設定
$ vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin gankai1104@gmail.com
DocumentRoot /var/www/test_code
ServerName test-code
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
シンボリックリンクの作成
$ cd /var/www $ ln -s ~/Codeigniter/ test-code
以上です。