前回、CakePHPに必要なApache、PHP、MySQLをインストールした。hirotaka-hachiya.hatenablog.com
今回は、下記のサイトを参考に、CakePHPの本体をインストールする。
http://book.cakephp.org/3.0/ja/installation.html
CakePHPは、依存管理ツールである Composer を使用してインストールする。
そのため、まずは、curlを用いてComposerをインストールする。
> curl -s https://getcomposer.org/installer | php #!/usr/bin/env php All settings correct for using Composer Downloading... Composer successfully installed to: /home/hachiya/Works/PHP/composer.phar >ls composer.phar
次に、インストールしたcomposerを用いてcakePHPのプロジェクトを作る。
cakePHPをインストールしていないのに、いきなりプロジェクトを作るのかよと思う方もいると思うが、
プロジェクトを作る際に、cakePHP本体と関連モジュールがインストールされるという仕組みのようだ。
とりあえず、testという名前のプロジェクトを作る。
php composer.phar create-project --prefer-dist cakephp/app test Installing cakephp/app (3.1.1) - Installing cakephp/app (3.1.1) Downloading: 100% Created project in test Loading composer repositories with package information Installing dependencies (including require-dev) - Installing aura/installer-default (1.0.0) Downloading: 100% - Installing cakephp/plugin-installer (0.0.12) Downloading: 100% - Installing psr/log (1.0.0) Downloading: 100% - Installing nesbot/carbon (1.13.0) Downloading: 100% - Installing mobiledetect/mobiledetectlib (2.8.17) Downloading: 100% - Installing aura/intl (1.1.1) Downloading: 100% - Installing ircmaxell/password-compat (v1.0.4) Downloading: 100% - Installing cakephp/cakephp (3.1.0) Downloading: 100% - Installing symfony/yaml (v2.7.4) Downloading: 100% - Installing symfony/filesystem (v2.7.4) Downloading: 100% - Installing symfony/config (v2.7.4) Downloading: 100% - Installing symfony/console (v2.7.4) Downloading: 100% - Installing robmorgan/phinx (v0.4.6) Downloading: 100% - Installing cakephp/migrations (1.3) Downloading: 100% - Installing jakub-onderka/php-console-color (0.1) Downloading: 100% - Installing jakub-onderka/php-console-highlighter (v0.3.2) Downloading: 100% - Installing dnoegel/php-xdg-base-dir (0.1) Downloading: 100% - Installing nikic/php-parser (v1.4.1) Downloading: 100% - Installing symfony/var-dumper (v2.7.4) Downloading: 100% - Installing psy/psysh (v0.5.2) Downloading: 100% - Installing jdorn/sql-formatter (v1.2.17) Downloading: 100% - Installing cakephp/debug_kit (3.2.0) Downloading: 100% - Installing cakephp/bake (1.1.0) Downloading: 100% symfony/console suggests installing symfony/event-dispatcher () symfony/console suggests installing symfony/process () symfony/var-dumper suggests installing ext-symfony_debug () psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.) cakephp/debug_kit suggests installing ext-sqlite (DebugKit needs to store panel data in a database. SQLite is simple and easy to use.) Writing lock file Generating autoload files > Cake\Composer\Installer\PluginInstaller::postAutoloadDump > App\Console\Installer::postInstall Created `config/app.php` file Set Folder Permissions ? (Default to Y) [Y,n]? Y Permissions set on /home/hachiya/Works/PHP/test/tmp/cache Permissions set on /home/hachiya/Works/PHP/test/tmp/cache/models Permissions set on /home/hachiya/Works/PHP/test/tmp/cache/persistent Permissions set on /home/hachiya/Works/PHP/test/tmp/cache/views Permissions set on /home/hachiya/Works/PHP/test/tmp/sessions Permissions set on /home/hachiya/Works/PHP/test/tmp/tests Permissions set on /home/hachiya/Works/PHP/test/tmp Permissions set on /home/hachiya/Works/PHP/test/logs Updated Security.salt value in config/app.php > ls composer.phar test > ls test README.md composer.json config logs plugins tests vendor bin composer.lock index.php phpunit.xml.dist src tmp webroot > ls test/bin cake cake.bat cake.php
「test」と言うフォルダが出来ていて、その中にindex.php, bin, tmp, logs, srcなどのフォルダが出来ているのがわかる。
また、test/binの中には、cakephp本体らしきものがインストールされているのがわかる。
このように、プロジェクトのフォルダが作成され、その中に、cakePHP一式がインストールされるようだ。
さて、このプロジェクトにブラウザからアクセスしてみる。そのためには、開発サーバというのを起動する。
> test/bin/cake server Welcome to CakePHP v3.1.0 Console --------------------------------------------------------------- App : src Path: /home/hachiya/Works/PHP/test/src/ DocumentRoot: /home/hachiya/Works/PHP/test/webroot --------------------------------------------------------------- built-in server is running in http://localhost:8765/ You can exit with `CTRL-C`
そして、ブラウザから「http://localhost:8765」にアクセスする。