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

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

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

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

Q&A

2回答

2494閲覧

gitでマージ競合後、リベースしたらcakePHPでのドキュメントルート以外が404エラーになってしまう

kphex

総合スコア42

CakePHP

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

0グッド

0クリップ

投稿2016/07/01 10:45

編集2022/01/12 10:55

###前提・実現したいこと
PHP(CakePHP)でadmin管理画面を作っています。
Vagrantで開発をしていたのですが急に404エラーとってしまいました。

という状況です。
特にエラーログは出ておらず、どこにあたりをつけたらよいかわからない状況です。

###該当のソースコード
もしかしたらwebroot/index.phpがミスっているのかとも思うのでこちらに掲載させていただきます。

/** * Index * * The Front Controller for handling every request * * @link http://cakephp.org CakePHP(tm) Project * @package app.webroot * @since CakePHP(tm) v 0.2.9 */ /** * Use the DS to separate the directories in other defines */ if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } /** * These defines should only be edited if you have CakePHP installed in * a directory layout other than the way it is distributed. * When using custom settings be sure to use the DS and do not add a trailing DS. */ /** * The full path to the directory which holds "app", WITHOUT a trailing DS. * */ if (!defined('ROOT')) { define('ROOT', dirname(dirname(dirname(__FILE__)))); } /** * The actual directory name for the "app". * */ if (!defined('APP_DIR')) { define('APP_DIR', basename(dirname(dirname(__FILE__)))); } /** * The absolute path to the "cake" directory, WITHOUT a trailing DS. * * Un-comment this line to specify a fixed path to CakePHP. * This should point at the directory containing `Cake`. * * For ease of development CakePHP uses PHP's include_path. If you * cannot modify your include_path set this value. * * Leaving this constant undefined will result in it being defined in Cake/bootstrap.php * * The following line differs from its sibling * /app/webroot/index.php */ //define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'); define( 'CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib' ); /** * This auto-detects CakePHP as a composer installed library. * You may remove this if you are not planning to use composer (not recommended, though). */ $vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) { define('CAKE_CORE_INCLUDE_PATH', $vendorPath); } /** * Editing below this line should NOT be necessary. * Change at your own risk. * */ if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', basename(dirname(__FILE__))); } if (!defined('WWW_ROOT')) { define('WWW_ROOT', dirname(__FILE__) . DS); } // for built-in server if (PHP_SAPI === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) { return false; } $_SERVER['PHP_SELF'] = '/' . basename(__FILE__); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { if (function_exists('ini_set')) { ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path')); } if (!include 'Cake' . DS . 'bootstrap.php') { $failed = true; } } else { if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') { $failed = true; } } if (!empty($failed)) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } App::uses('Dispatcher', 'Routing'); $Dispatcher = new Dispatcher(); $Dispatcher->dispatch( new CakeRequest(), new CakeResponse() );

###試したこと
hogehoge.com → 問題なし
hogehoge.com/fuga/ → 404
hogehoge.com/index.php/fuga/ →なぜかOK?

###補足情報(言語/FW/ツール等のバージョンなど)
cakephp2.8.5
Vagrant 1.8.1
centOS 7.1
php 5.6.3

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

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

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

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

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

guest

回答2

0

一度マージに失敗して競合が起こってしまいました。

そこでリベースをして戻したところ

マージをやり直すコマンドはgit merge --abortであって、git rebaseではありません。

ローカルリポジトリ(Vagrant上のリポジトリ)でgit statusコマンドを実行してみてください。

$ git status (中略) You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add <file>..." to mark resolution) both modified: (ファイル名)

のように表示されるのであれば、git merge --abortで、マージ前の状態に戻せるはずです。

投稿2016/07/02 09:29

編集2016/07/02 09:29
KiyoshiMotoki

総合スコア4791

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

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

0

ファイル構成がわからないと何とも言えませんが、与えられた情報だけで判断すると。
fugaコントローラーというのがあるのですか?
Cakeの命名規約だとfugasになるような気がするのですが
hogehoge.com/fugas/

それはおいておいても、デフォルトでpagesコントローラーがあるかと思いますが、もしまだ残しているのであればそれは表示されますか?
表示されるのであれば、作ったコントローラーのほうの記載がおかしいのかもしれません。
pagesコントローラもおかしいのであれば、webrootのindex.phpや.htaccessファイルを確認してみてください。
とりあえず、cakeの元のファイルとの差分をとってみてはどうでしょうか?

投稿2016/07/01 12:55

CodeLab

総合スコア1939

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問