質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

CakePHP

CakePHPは、PHPで書かれたWebアプリケーション開発用のフレームワークです。 Ruby on Railsの考え方を多く取り入れており、Railsの高速性とPHPの機動性を兼ね備えています。 MVCやORMなどを「規約優先の考え方」で利用するため、コードを書く手間を省くことができます。 外部のライブラリに依存しないので、単体での利用が可能です。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

Q&A

1回答

9692閲覧

cakephpで簡易サーバーを立ち上げようとしたが、autoload.phpがない

Piesuke

総合スコア15

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

CakePHP

CakePHPは、PHPで書かれたWebアプリケーション開発用のフレームワークです。 Ruby on Railsの考え方を多く取り入れており、Railsの高速性とPHPの機動性を兼ね備えています。 MVCやORMなどを「規約優先の考え方」で利用するため、コードを書く手間を省くことができます。 外部のライブラリに依存しないので、単体での利用が可能です。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

0グッド

2クリップ

投稿2018/04/10 06:51

編集2022/01/12 10:55

cakephpを使ってアプリを開発しようとしています。サーバーはvagrantを使っており,OSはcentos7です。

[vagrant@localhost myapp]$ bin/cake server -H 192.168.33.10 -p 8000

で簡易サーバーを立ち上げようとしたところ、

PHP Warning: require(/home/vagrant/cake1/myapp/vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/cake1/myapp/bin/cake.php on line 5 PHP Fatal error: require(): Failed opening required '/home/vagrant/cake1/myapp/vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/vagrant/cake1/myapp/bin/cake.php on line 5

と出ました。vendorの中はemptyになっていました。

対処法を教えて欲しいです。よろしくお願いいたします。

【追記】
php composer.phar install した時のエラー

Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - cakephp/cakephp-codesniffer 3.0.0 requires squizlabs/php_codesniffer ^3.0.0 -> satisfiable by squizlabs/php_codesniffer[3.0.0, 3.0.1, 3.0.2, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3]. - cakephp/cakephp-codesniffer 3.0.1 requires squizlabs/php_codesniffer ^3.0.0 -> satisfiable by squizlabs/php_codesniffer[3.0.0, 3.0.1, 3.0.2, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3]. - cakephp/cakephp-codesniffer 3.0.2 requires squizlabs/php_codesniffer ~3.0.0 -> satisfiable by squizlabs/php_codesniffer[3.0.0, 3.0.1, 3.0.2]. - cakephp/cakephp-codesniffer 3.0.3 requires squizlabs/php_codesniffer ^3.0.0 -> satisfiable by squizlabs/php_codesniffer[3.0.0, 3.0.1, 3.0.2, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3]. - squizlabs/php_codesniffer 3.2.3 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.2.2 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.2.1 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.2.0 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.1.1 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.1.0 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.0.2 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.0.1 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - squizlabs/php_codesniffer 3.0.0 requires ext-simplexml * -> the requested PHP extension simplexml is missing from your system. - Installation request for cakephp/cakephp-codesniffer ^3.0 -> satisfiable by cakephp/cakephp-codesniffer[3.0.0, 3.0.1, 3.0.2, 3.0.3]. To enable extensions, verify that they are enabled in your .ini files: - /etc/php.ini - /etc/php.d/20-bz2.ini - /etc/php.d/20-calendar.ini - /etc/php.d/20-ctype.ini - /etc/php.d/20-curl.ini - /etc/php.d/20-exif.ini - /etc/php.d/20-fileinfo.ini - /etc/php.d/20-ftp.ini - /etc/php.d/20-gd.ini - /etc/php.d/20-gettext.ini - /etc/php.d/20-iconv.ini - /etc/php.d/20-intl.ini - /etc/php.d/20-json.ini - /etc/php.d/20-mbstring.ini - /etc/php.d/20-pdo.ini - /etc/php.d/20-phar.ini - /etc/php.d/20-sockets.ini - /etc/php.d/20-sqlite3.ini - /etc/php.d/20-tokenizer.ini - /etc/php.d/30-pdo_sqlite.ini You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

phpのバージョンは 7.0.29で、composer.jsonの内容は

{ "name": "cakephp/app", "description": "CakePHP skeleton app", "homepage": "https://cakephp.org", "type": "project", "license": "MIT", "require": { "php": ">=5.6", "cakephp/cakephp": "3.5.*", "cakephp/migrations": "^1.0", "cakephp/plugin-installer": "^1.0", "josegonzalez/dotenv": "2.*", "mobiledetect/mobiledetectlib": "2.*" }, "require-dev": { "cakephp/bake": "^1.1", "cakephp/cakephp-codesniffer": "^3.0", "cakephp/debug_kit": "^3.2", "psy/psysh": "@stable" }, "suggest": { "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.", "phpunit/phpunit": "Allows automated tests to be run without system-wide install.", "cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP." }, "autoload": { "psr-4": { "App\": "src/" } }, "autoload-dev": { "psr-4": { "App\Test\": "tests/", "Cake\Test\": "vendor/cakephp/cakephp/tests/" } }, "scripts": { "post-install-cmd": "App\Console\Installer::postInstall", "post-create-project-cmd": "App\Console\Installer::postInstall", "post-autoload-dump": "Cake\Composer\Installer\PluginInstaller::postAutoloadDump", "check": [ "@test", "@cs-check" ], "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests", "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests", "test": "phpunit --colors=always" }, "prefer-stable": true, "config": { "sort-packages": true } }

です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

composer install を実行してないからではないでしょうか。

myapp/ ディレクトリに composer.json ファイルがあるかと思いますので、myapp/ ディレクトリで composer install を実行する必要があります。

成功すると、vendor/ ディレクトリに必要なパッケージがインストールされて、autoload.php も作成されるはずです。

投稿2018/04/10 06:56

編集2018/04/10 07:00
Lulucom

総合スコア1899

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Piesuke

2018/04/10 07:04

composer install を行ったら、command not foundとなり実行されませんでした。
Lulucom

2018/04/10 07:13

Composer がインストールされていないのかもしれませんね。ご確認ください。
Piesuke

2018/04/10 09:03

貼ってくださいましたURLを元にcomposerをインストールしたのですが、未だcomposerコマンドが使えません。 php composer.phar で確認したらcomposerは入っているので、composerはインストールされていると思います。
Lulucom

2018/04/10 09:13

`composer install` の代わりに `php composer.phar install` を実行してください。
Piesuke

2018/04/10 09:14

実行しましたがvendorの中は空のままです。
Lulucom

2018/04/10 12:01 編集

php composer.phar install を実行したときの出力はどんな感じでしたか?エラーなどは出ていませんか?
Piesuke

2018/04/11 00:36

めっちゃエラー出てました。追記に記入しました。
退会済みユーザー

退会済みユーザー

2018/04/11 00:49

extensionがたりねーよですな。 phpのインストールと同様の操作で エラーにでているextensionを追加しましょ
Lulucom

2018/04/11 00:53 編集

めっちゃ出てましたね、ありがとうございます。念のためcomposer.jsonの内容やPHPのバージョンとかも明記されると良いかと思います。
退会済みユーザー

退会済みユーザー

2018/04/11 00:57

Probrem 単位が 一つのエラーで利用環境にあったものを探しているログだったりする
Lulucom

2018/04/11 01:02

asahinaさん、ありがとうございます、"the requested PHP extension simplexml is missing from your system." がエラーということなんですね。
Lulucom

2018/04/11 01:14

Piesukeさん、 "the requested PHP extension simplexml is missing from your system." centos7 vagrant あたりで検索してみると、同じような問題への対処法がわかりそうですよ。
Piesuke

2018/04/11 01:21

phpのバージョンとcomposer.jsonを追記しました。 検索してみます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問