ll -R

ファイル一覧を取得したい

[vagrant@localhost zend]$ ll -R
.:
合計 112
-rw-rw-r–. 1 vagrant vagrant 2378 10月 31 23:23 2017 CONDUCT.md
-rw-rw-r–. 1 vagrant vagrant 6878 10月 31 23:23 2017 CONTRIBUTING.md
-rw-rw-r–. 1 vagrant vagrant 398 10月 31 23:23 2017 Dockerfile
-rw-rw-r–. 1 vagrant vagrant 1517 10月 31 23:23 2017 LICENSE.md
-rw-rw-r–. 1 vagrant vagrant 6526 10月 31 23:23 2017 README.md
-rw-rw-r–. 1 vagrant vagrant 504 10月 31 23:23 2017 TODO.md
-rw-rw-r–. 1 vagrant vagrant 1828 10月 31 23:23 2017 Vagrantfile
-rw-rw-r–. 1 vagrant vagrant 1282 8月 5 20:50 2019 composer.json
-rw-rw-r–. 1 vagrant vagrant 37916 8月 5 20:50 2019 composer.lock
drwxrwxr-x. 3 vagrant vagrant 4096 8月 5 20:50 2019 config
drwxrwxr-x. 3 vagrant vagrant 4096 10月 31 23:23 2017 data
-rw-rw-r–. 1 vagrant vagrant 91 10月 31 23:23 2017 docker-compose.yml
drwxrwxr-x. 3 vagrant vagrant 4096 10月 31 23:23 2017 module
-rw-rw-r–. 1 vagrant vagrant 997 10月 31 23:23 2017 phpcs.xml
-rw-rw-r–. 1 vagrant vagrant 253 10月 31 23:23 2017 phpunit.xml.dist
drwxrwxr-x. 6 vagrant vagrant 4096 10月 31 23:23 2017 public
drwxrwxr-x. 8 vagrant vagrant 4096 8月 5 20:50 2019 vendor

./config:
合計 20
-rw-rw-r–. 1 vagrant vagrant 2894 10月 31 23:23 2017 application.config.php
drwxrwxr-x. 2 vagrant vagrant 4096 8月 5 20:50 2019 autoload
-rw-rw-r–. 1 vagrant vagrant 665 8月 5 20:50 2019 development.config.php
-rw-rw-r–. 1 vagrant vagrant 665 10月 31 23:23 2017 development.config.php.dist
-rw-rw-r–. 1 vagrant vagrant 485 10月 31 23:23 2017 modules.config.php

./config/autoload:
合計 28
-rw-rw-r–. 1 vagrant vagrant 376 10月 31 23:23 2017 README.md
-rw-rw-r–. 1 vagrant vagrant 527 8月 5 20:50 2019 development.local.php
-rw-rw-r–. 1 vagrant vagrant 527 10月 31 23:23 2017 development.local.php.dist
-rw-rw-r–. 1 vagrant vagrant 425 10月 31 23:23 2017 global.php
-rw-rw-r–. 1 vagrant vagrant 513 10月 31 23:23 2017 local.php.dist
-rw-rw-r–. 1 vagrant vagrant 5922 10月 31 23:23 2017 zend-developer-tools.local-development.php

うーん、なんか違う

再度zendをインストールしてみよう

3度目の正直
[vagrant@localhost zend]$ php composer.phar create-project zendframework/skeleton-application zend

Generating autoload files

Do you want a minimal install (no optional packages)? Y/n
y
Removing optional packages from composer.json
Updating composer.json
Removing zendframework/zend-skeleton-installer…
– Removing zendframework/zend-skeleton-installer (0.1.4)
Removed plugin zendframework/zend-skeleton-installer.
Removing from composer.json
Complete!
> zf-development-mode enable
You are now in development mode.
[vagrant@localhost zend]$ ls
composer.phar zend zf2
[vagrant@localhost zend]$ cd zend
[vagrant@localhost zend]$ ls
CONDUCT.md LICENSE.md Vagrantfile config module public
CONTRIBUTING.md README.md composer.json data phpcs.xml vendor
Dockerfile TODO.md composer.lock docker-compose.yml phpunit.xml.dist
[vagrant@localhost zend]$ cd public
[vagrant@localhost public]$ php -S 192.168.33.10:8000
PHP 5.6.40 Development Server started at Mon Aug 5 20:51:02 2019
Listening on http://192.168.33.10:8000
Document root is /home/vagrant/zend/zend/public
Press Ctrl-C to quit.
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64689 [200]: /
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64691 [200]: /css/bootstrap-theme.min.css
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64690 [200]: /css/bootstrap.min.css
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64692 [200]: /css/style.css
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64693 [200]: /js/jquery-3.1.0.min.js
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64694 [200]: /js/bootstrap.min.js
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64695 [200]: /img/zf-logo-mark.svg
[Mon Aug 5 20:51:08 2019] 192.168.33.1:64696 [200]: /img/favicon.ico

お、なんか来た

3度目の正直なんて普通はないんだけどね。
もっとペース上げるか。

application.config.php

[vagrant@localhost ZendSkeletonApplication]$ ls
CONDUCT.md LICENSE.md Vagrantfile config module public
CONTRIBUTING.md README.md composer.json data phpcs.xml vendor
Dockerfile TODO.md composer.lock docker-compose.yml phpunit.xml.dist
[vagrant@localhost ZendSkeletonApplication]$ cd config
[vagrant@localhost config]$ ls
application.config.php autoload development.config.php.dist modules.config.php

zend

[vagrant@localhost www]$ git clone https://github.com/zendframework/ZendSkeletonApplication.git
fatal: could not create work tree dir ‘ZendSkeletonApplication’.: Permission denied
[vagrant@localhost www]$ sudo git clone https://github.com/zendframework/ZendSkeletonApplication.git
Initialized empty Git repository in /var/www/ZendSkeletonApplication/.git/
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 3743 (delta 1), reused 4 (delta 1), pack-reused 3736
Receiving objects: 100% (3743/3743), 2.61 MiB | 1.17 MiB/s, done.
Resolving deltas: 100% (1772/1772), done.
[vagrant@localhost www]$ ls
ZendSkeletonApplication cgi-bin error html icons
[vagrant@localhost www]$ cd ZendSkeletonApplication
[vagrant@localhost ZendSkeletonApplication]$ ls
CONDUCT.md README.md composer.lock module
CONTRIBUTING.md TODO.md config phpcs.xml
Dockerfile Vagrantfile data phpunit.xml.dist
LICENSE.md composer.json docker-compose.yml public
[vagrant@localhost ZendSkeletonApplication]$ sudo cp -r /home/vagrant/zend/zf2/vendor vendor
[vagrant@localhost ZendSkeletonApplication]$ ls
CONDUCT.md README.md composer.lock module vendor
CONTRIBUTING.md TODO.md config phpcs.xml
Dockerfile Vagrantfile data phpunit.xml.dist
LICENSE.md composer.json docker-compose.yml public
[vagrant@localhost ZendSkeletonApplication]$ cd public
[vagrant@localhost public]$ ls
css fonts img index.php js web.config
[vagrant@localhost public]$ php -S 192.168.33.10:8000
PHP 5.6.40 Development Server started at Thu Aug 1 23:56:44 2019
Listening on http://192.168.33.10:8000
Document root is /var/www/ZendSkeletonApplication/public
Press Ctrl-C to quit.
[Thu Aug 1 23:56:47 2019] PHP Fatal error: Uncaught exception ‘Zend\ModuleManager\Exception\RuntimeException’ with message ‘Module (Application) could not be initialized.’ in /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203
Stack trace:
#0 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97): Zend\ModuleManager\ModuleManager->loadModule(‘Application’)
#2 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#4 /var/www/ZendSkeletonApplication/vendo in /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203
[Thu Aug 1 23:56:47 2019] 192.168.33.1:56286 [500]: / – Uncaught exception ‘Zend\ModuleManager\Exception\RuntimeException’ with message ‘Module (Application) could not be initialized.’ in /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php:203
Stack trace:
#0 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(175): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php(97): Zend\ModuleManager\ModuleManager->loadModule(‘Application’)
#2 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 /var/www/ZendSkeletonApplication/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\ModuleManager\ModuleEvent))
#4 /var/www/ZendSkeletonApplication/vendo in /var/www/ZendSkeletonApplication/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203
[Thu Aug 1 23:57:00 2019] 192.168.33.1:56287 Invalid request (Unexpected EOF)
[Thu Aug 1 23:57:00 2019] 192.168.33.1:56288 Invalid request (Unexpected EOF)

application.config?

'module_paths' => [
           dirname(__FILE__) . '/../module',
           dirname(__FILE__) . '/../vendor',
        ],

こうじゃないのか?

gitでzendを入れてみよう

[vagrant@localhost zend]$ git clone https://github.com/zendframework/zf2.git
Initialized empty Git repository in /home/vagrant/zend/zf2/.git/
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 358463 (delta 0), reused 0 (delta 0), pack-reused 358462
Receiving objects: 100% (358463/358463), 96.73 MiB | 836 KiB/s, done.
Resolving deltas: 100% (266705/266705), done.
[vagrant@localhost zend]$ ls
composer.phar zf2

[vagrant@localhost zend]$ cd zf2
[vagrant@localhost zf2]$ ls
CHANGELOG.md LICENSE.md README.md composer.json resources
[vagrant@localhost zf2]$ curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading…

Composer (version 1.8.6) successfully installed to: /home/vagrant/zend/zf2/composer.phar
Use it: php composer.phar

改めてZend Frameworkを始めよう

公式を見ると、どうやらcomposerで入れるのが手っ取り早そうですね。
https://framework.zend.com/downloads

まず、composerを落としてきます。
[vagrant@localhost zend]$ curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading…

Composer (version 1.8.6) successfully installed to: /home/vagrant/zend/composer.phar
Use it: php composer.phar

[vagrant@localhost zend]$ ls
composer.phar

composerでzendframeworkを入れていきます。
[vagrant@localhost zend]$ php composer.phar require zendframework/zendframework
Using version ^3.0 for zendframework/zendframework
./composer.json has been created

あれ、

[vagrant@localhost zend]$ php composer.phar serve

[Symfony\Component\Console\Exception\CommandNotFoundException]
Command “serve” is not defined.

あれ、なんでや

Zend Frameworkを始めよう

Zend Frameworkって古くないか? という話はさて置き、Zendを使っていきたいと思います。PHP初のframeworkなら、割と優れたところも多いでしょう、という勝手な思い込みで。MVCかな?

まずバージョンを調べます。

echo zend_version();


あれ、もう入ってる?

[vagrant@localhost ~]$ mkdir zend
[vagrant@localhost ~]$ cd zend
[vagrant@localhost zend]$ zf create project projectZ
bash: zf: コマンドが見つかりません

どっちやねん。インストールが必要のようです。

[vagrant@localhost zend]$ sudo yum -y install –enablerepo=remi php-ZnedFramework
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
epel/metalink | 8.2 kB 00:00
* base: ftp.jaist.ac.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.jaist.ac.jp
* remi: ftp.riken.jp
* remi-safe: ftp.riken.jp
* updates: ftp.jaist.ac.jp
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql56-community | 2.5 kB 00:00
nodesource | 2.5 kB 00:00
remi | 3.0 kB 00:00
remi/primary_db | 2.4 MB 00:02
remi-safe | 3.0 kB 00:00
updates | 3.4 kB 00:00
パッケージ php-ZnedFramework は利用できません。
エラー: 何もしません

何いいいいいいい