6

HMVCパターンで実行されている私のプロジェクトにionauthを使用することに興味があります。アプリケーションはCodeigniterで書かれています。

私が直面している問題は、ionauthが/app / modules / authフォルダーに配置された後、モジュールにアクセスしようとすると、次のエラーが発生することです。

HTTPエラー500(内部サーバーエラー)
サーバーが要求を実行しようとしたときに、予期しない状態が発生しました。

ここで私を助けてください、私はある種の構成/パスの問題を抱えていると確信していますが、どこにあるのかわかりません。

githubからion_authファイルをダウンロードし、抽出したファイルをそのままモジュールフォルダーに配置しました。構成を使用して自動ロードしたため、データベース、セッションなどのライブラリをロードするすべての行を削除しました。しかし、ion_authライブラリのロードは終了しました。

モジュールフォルダーmodules/authには、モジュール固有の構成、ライブラリなどのフォルダーを持つ同様のアプリケーション構造があります。

どこで間違ったことをしたに違いないか教えてください。運が良ければ、この問題を検索して修正し、投稿します。

4

6 に答える 6

10

CI 2.1 + Modular Extensions 5.4 + IonAuth2がすべて機能しました。

私はこれに関する正確な情報を実際には見ていませんでした、そして私が見たものはルーティングやそれらが行われたように動作することができなかったもののようなものがたくさんあったので、私は私がしたことを共有することにしましたこれを達成するために。

最初は苦労していましたが、その後、何が起こっているのかを考えなければなりませんでした。

その後、それは実際にはかなり簡単で、ほんの2、3の落とし穴がありました…</ p>

IONAUTHをCodeIgniter+MXHMVCで動作させるために行った手順

  1. CodeIgnterをインストールします(実際に作業中の既存のプロジェクトを使用したため、新しいクリーンインストールではありませんでした。「index.php」を削除し、HMVCに推奨される方法をすでにインストールしました。これはとにかくIon Authに関するものです。)

  2. IonAuthの最新バージョンを入手してください。

  3. Ion Authをにインストールする代わりにapplication/third_party、解凍して、結果のディレクトリの名前をに変更しauthます。application/modules結果が。になるように入れてくださいapplication/modules/auth

  4. IonAuthのSQLを実行してテーブルを設定します。

  5. 行を次のようにapplication/config/autoload.php更新します。

    $autoload['libraries'] = array('database','session');
    
  6. modules/auth/libraries/Ion_auth.phpの行を更新し__constructます。

    $this->ci->load->config('auth/ion_auth', TRUE);
    $this->ci->load->library('email');
    $this->ci->load->library('session');
    $this->ci->lang->load('auth/ion_auth');
    $this->ci->load->model('auth/ion_auth_model')
    
  7. modules/auth/models/ion_auth_model.phpの行を更新し__constructます。

    $this->load->config('auth/ion_auth', TRUE);
    $this->load->helper('cookie');
    $this->load->helper('date');
    $this->load->library('session');
    $this->lang->load('auth/ion_auth');
    
  8. authコントローラ( )をデフォルトの代わりにmodules/auth/controllers/auth.php拡張するように変更します。MX_ControllerCI_Controller

  9. さて、でauth.php、必ずすべて$this->data$data -に変更してください(これについては以下で必ずお読みください!!)。

  10. ファイルとディレクトリをに移動しmodules/auth/views/authmodules/auth/viewsmodules/auth/views下位レベルのauthディレクトリがないようにします-(これについては以下で必ずお読みください!!)。

  11. ルート.phpファイルをmodules/auth / configに追加し、次の行を追加します。

    $route['auth/(:any)'] = "auth/$1";
    
  12. さあ、に行ってhttp://yoursite/authください。すべてがうまくいくはずです。

ガッチャ

まず最初に..application/config/autoload.phpファイル内のライブラリまたはモデルを自動ロードしないでください。モジュール内で$this->load->library("whatever")、などを使用して明示的に実行してください…</ p>

それはかなり長い間私を困惑させました。

現在のインストールでは、URLからindex.phpをすでに削除しており、インストールのベースに.htaccessファイルがあることを忘れました。うまくいかない場合は、おそらくここのRewriteBaseに問題があります。これは私が使用する.htaccessです:

## Set up mod_rewrite
<IfModule mod_rewrite.c>
Options +MultiViews +FollowSymLinks
DirectoryIndex index.php index.html

# Enable Rewrite Engine
# ------------------------------
RewriteEngine On

# UPDATE THIS TO POINT TO where you installed this FROM YOUR DOC ROOT.
# If this is in the DOC ROOT, leave it as it is
#---------------------
RewriteBase /

# In case your hosting service doesn't add or remove 'www.' for you, you can
# do it here by uncommenting and updating the 'Rewrite*'s below.
#
# Add or remove 'www.'  Whichever you prefer.  
# This one removes the 'www.' which seems to be the favorable choice these days. 
# ------------------------------
#RewriteCond %{HTTP_HOST} ^www.<sitename>.com
#RewriteRule (.*) http://<sitename>.com/$1 [R=301,L]

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) $1$2 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteRule modules/(.+)/controllers/(.+)\.php$ /index.php?/$1/$2 [L,R=301]
RewriteRule controllers/(.+)\.php$ /index.php?/$1 [L,R=301]

RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

=================================

modules / auth / controllers / auth.phpを更新してCI_ControllerではなくMX_Controllerを拡張すると、その後一連のエラーが発生していました。これらのエラーの最初のものは次のとおりです。

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: CI::$data

    Filename: MX/Controller.php

このエラーを解決するために、コントローラーのすべて$this->dataをに変更しました。$dataauth.php

この問題を修正した後、に行くとauth、次のようなエラーが発生します。

Unable to load the requested file: auth/login.php

どうやら、それはそれ自身のディレクトリでビューファイルを見つけることができませんviews。ああ。それについて考えた後でも、正確には真実ではありません。その理由は、それが見つけようとしているので、中module/file_to_viewにあるfile_to_viewべきだからviewsです!入ってないauth/views/auth!! したがって、すべてをdirからauthdirに移動する必要がありviewsます。

その後、すべてが正常に動作します!他のモジュールでモデル、ライブラリ、コントローラーをクロスロードでき、ビューやその他すべてでModules :: run()を実行できます。

これが他の誰かに役立つことを願っています。幸運を!

于 2011-12-24T21:01:37.413 に答える
10

これを試して:

  1. 取得: codeigniter.zip (CI2.0)
  2. 抽出し、実行中であることを確認し、config/config.php を設定します
  3. モジュラー拡張を取得: HMVC
  4. インストール - MY_Loader と MY_Router を /core に、MX をサードパーティのフォルダーにコピーします MY_Controller をコピーしないでください - これはモジュラー分離用であり、拡張機能用ではありません
  5. Ion_authを取得する
  6. Ion_auth の SQL をインストールします。
  7. Ion_auth をモジュール フォルダー /application/modules/users に配置します。
  8. config/routes.php にルートを追加します: $route['auth/(.*)'] = 'users/auth/$1';

  9. 自動ロードion_auth -$autoload['libraries'] = array('database','session','users/ion_auth');

  10. modules/users/library/ion_auth.php で次のパスを編集します。

    $this->ci->load->config('users/ion_auth', TRUE);
    $this->ci->load->library('email');
    $this->ci->load->library('session');
    $this->ci->lang->load('users/ion_auth');
    $this->ci->load->model('users/ion_auth_model');
    
于 2011-08-09T21:22:14.180 に答える
1

これは、ciuserのガイドラインに従って行ったものですが、いくつかの変更があります。

  1. Codeigniter のクリーン インストールを実行します。config.php、database.php などを設定します。
  2. モジュラー拡張機能のインストール:
    third_party/MX を CI/application/third_party に移動します。
    core/MY_Loader.php と core/MY_Router.php を CI/application/core に移動します。
  3. Ion Auth をインストールします
    。次の Ion Auth フォルダーを CI/application/modules/auth フォルダーに移動します: config、controllers、language、libraries、models。
    Ion Auth/views フォルダーの下にあるファイルを CI/application/modules/auth/views に移動します。(Ion Auth のように 1 つの認証レイヤーを追加する必要はありません。)
    データベースで Ion Auth sql を実行します。
  4. yourbaseurl/index.php/auth で確認してください。
于 2011-10-29T17:15:32.273 に答える
1

うまくいかない理由がわかりません。パイロムをチェック

彼らはhmvcでionauthを使用しています。

動作しない場合は、通常の ci ディレクトリにファイルをアップロードして、問題なく動作するかどうかを確認してください。

于 2011-06-15T05:52:13.060 に答える
1

CodeIgniter 2 + Modular Extensions 5.4 + Ion Auth 2 を取得してインストールするための bash スクリプトを作成しました。

ここにあります。頑張ってください。問題がある場合はお知らせください。

#! /bin/bash

echo "

This will install Codeigniter 2, Modular Extensions 5.4 and Ion Auth 2!

This script will TRY to download the packages for you.
-----------------------------------------------------
The resulting CodeIgniter install is already configured to remove the index.php
from the URL and should ALMOST be ready to run!  Make sure to read the
steps at the end of this.


Good luck..


Hit a key to continue or Ctrl-c to cancel now."


read

## Download the files
echo "Get CodeIgniter"
wget -O CodeIgniter.zip http://codeigniter.com/download.php

echo "Get Ion Auth"
wget --no-check-certificate -O benedmunds-ion-auth.zip https://github.com/benedmunds/CodeIgniter-Ion-Auth/zipball/2

echo "Get Modular Extensions"
wget --no-check-certificate -O wiredesignz.zip https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/get/tip.zip

## Unpack all the files
echo "Unpack Files"
unzip CodeIgniter.zip
rm CodeIgniter.zip
unzip benedmunds-ion-auth.zip
rm benedmunds-ion-auth.zip
unzip wiredesignz.zip
rm wiredesignz.zip

## Get the Dirs
echo "Find Dirs"
CI_DIR=`ls -c1 | grep ^CodeIgniter_`
ME_DIR=`ls -c1 | grep ^wired`
IA_DIR=`ls -c1 | grep ^ben`

## Make Modules Dir
echo "Make Modules Dir"
mkdir $CI_DIR/application/modules

## Move the Modular Extensions Files Into Place
echo "Move Modular Extensions files"
mv $ME_DIR/third_party/MX $CI_DIR/application/third_party
mv $ME_DIR/core/* $CI_DIR/application/core/

## Remove the Modular Extension Dir
echo "Remove ME Install Dir"
rm -rf $ME_DIR

## Make Welcome Module Dir
echo "Make Modular Welcome Dir"
mkdir -p $CI_DIR/application/modules/welcome/controllers

## Move default welcome controller to the modules dir
echo "Move Welcome Controller into Modules"
mv $CI_DIR/application/controllers/welcome.php $CI_DIR/application/modules/welcome/controllers/


## Make Welcome Views Dir
echo "Make Welcome Views Dir"
mkdir -p $CI_DIR/application/modules/welcome/views

## Move Welcome View into modular dir
echo "Move Welcome views into modular Welcome Dir"
mv $CI_DIR/application/views/welcome_message.php $CI_DIR/application/modules/welcome/views/

## Rename Ion Auths Dir to Auth
echo "Rename Ion Auth Dir to Auth"
mv $IA_DIR $CI_DIR/application/modules/auth

## Update the Welcome Controller to extend MX_Controller instead of CI_Controller
echo "Update Welcome Controller to extend MX_Controller"
sed -i -e "s/CI_Controller/MX_Controller/" $CI_DIR/application/modules/welcome/controllers/welcome.php

## Update the default autoload file to include database and session libraries
echo "Update autoload file to include the database and session libraries"
sed -i -e "s/\$autoload\['libraries'] = array()/\$autoload['libraries'] = array('database','session')/" $CI_DIR/application/config/autoload.php

## Update the config file to remove index.php
echo "Update config file to remove index.php"
sed -i -e "s/\$config\['index_page'] = 'index.php';/\$config['index_page'] = '';/" $CI_DIR/application/config/config.php

## Update the Ion Auth libraries to use the auth resource
echo "Update Ion Auth Lib to use the Auth Resources"
sed -i -e "s/\$this->ci->load->config('ion_auth', TRUE);/\$this->ci->load->config('auth\/ion_auth', TRUE);/" $CI_DIR/application/modules/auth/libraries/Ion_auth.php
sed -i -e "s/\$this->ci->lang->load('ion_auth');/\$this->ci->lang->load('auth\/ion_auth');/" $CI_DIR/application/modules/auth/libraries/Ion_auth.php
sed -i -e "s/\$this->ci->load->model('ion_auth_model');/\$this->ci->load->model('auth\/ion_auth_model');/" $CI_DIR/application/modules/auth/libraries/Ion_auth.php

## Update the Ion Auth model to use the auth resource
echo "Update the Ion Auth Model to use the Auth Resources"
sed -i -e "s/\$this->load->config('ion_auth', TRUE);/\$this->load->config('auth\/ion_auth', TRUE);/" $CI_DIR/application/modules/auth/models/ion_auth_model.php
sed -i -e "s/\$this->lang->load('ion_auth')/\$this->lang->load('auth\/ion_auth')/" $CI_DIR/application/modules/auth/models/ion_auth_model.php

## Update the Auth Controller to extend MX_Controller instead of CI_Controller
echo "Update Auth Controller to extend MX_Controller"
sed -i -e "s/CI_Controller/MX_Controller/" $CI_DIR/application/modules/auth/controllers/auth.php

## Update the Auth Controller so "$this->data" will be "$data"
echo "Update the Auth Controller to change \$this->data to \$data"
sed -i -e "s/\$this->data/\$data/" $CI_DIR/application/modules/auth/controllers/auth.php

## Move auth/views files up 1 level
echo "Move auth/views files up 1 level"
mv $CI_DIR/application/modules/auth/views/auth/* $CI_DIR/application/modules/auth/views/

## Remove the auth/views/auth dir
echo "Remove the auth/views/auth dir"
rmdir $CI_DIR/application/modules/auth/views/auth

## Make the routes.php file
echo "Write the modules/auth/config/routes.php file"
echo "<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
*/

\$route['auth/(:any)'] = \"auth/\$1\";

/* End of file routes.php */
/* Location: ./application/config/routes.php */


" > $CI_DIR/application/modules/auth/config/routes.php

echo "Creating the $CI_DIR/.htaccess file"
echo "## Set up mod_rewrite

<IfModule mod_rewrite.c>
Options +MultiViews +FollowSymLinks
DirectoryIndex index.php index.html

# Enable Rewrite Engine
# ------------------------------
RewriteEngine On

# UPDATE THIS TO POINT TO where you installed this FROM YOUR DOC ROOT.
# If this is in the DOC ROOT, leave it as it is
#---------------------
RewriteBase /

# In case your hosting service doesn't add or remove 'www.' for you, you can
# do it here by uncommenting and updating the 'Rewrite*'s below.
#
# Add or remove 'www.'  Whichever you prefer.  
# This one removes the 'www.' which seems to be the favorable choice these days. 
# ------------------------------
#RewriteCond %{HTTP_HOST} ^www.<sitename>.com
#RewriteRule (.*) http://<sitename>.com/\$1 [R=301,L]

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) \$1\$2 [R=301,L]


# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteRule modules/(.+)/controllers/(.+)\.php\$ /index.php?/\$1/\$2 [L,R=301]
RewriteRule controllers/(.+)\.php\$ /index.php?/\$1 [L,R=301]

RewriteCond \$1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\$ index.php/\$1 [L]

</IfModule>" > $CI_DIR/.htaccess

echo "

*********** DON'T FORGET THESE STEPS ***********
====================================================================

6 more steps:
==================
1) Update the \$config['base_url'] var in application/config/config.php
2) Update the \$config['encryption_key'] var in application/config/config.php
3) Update your application/config/database.php file to work with your database,
4) Run the Ion Auth SQL file located in application/modules/auth/sql.
5) Now rename or move everything from $CI_DIR into where you set \$config['base_url']

If you put your CodeIgniter files anywhere other than DOC ROOT you need to do step 6:
6)Update the 'RewriteBase' in the .htaccess file in your CodeIgniter Directory to where your CodeIgniter files are.

If your CodeIgniter files ARE IN the DOC ROOT of your webserver, you should be able to run from there like this:
---------------
yourdomain.com
yourdomain.com/auth


If your CodeIgniter files AREN'T IN the DOC ROOT:
Remember to update the RewriteBase to point to "your_ci_dir" (see below) in the .htaccess file and you should be able to run like this:
--------------------------
yourdomain.com/your_ci_dir
yourdomain.com/your_ci_dir/auth

====================================================================
    YOU SHOULD BE DONE AFTER FOLLOWING THOSE STEPS!

I think you should be up and running!


Hope this all works!


Please let me know if this worked for you or not!
Edmund - edmundchaniii AT gmail.com

C'ya!

"
于 2012-01-05T01:09:23.050 に答える