お世話になります、IdiormクラスがIdiormBaseクラスを継承しており、そのIdiormBaseクラスの中でidiorm.phpのORMクラスを呼び出したいのですが、ディレクトリが違うので、うまく呼べず、Slim Application Errorとなってしまいます。
Message: Class 'mycontroller\idiorm\ORM' not found
php
1<?php 2namespace mycontroller; 3 4class Idiorm extends IdiormBase 5{ 6 7 public function find($id) 8 { 9 10 $user = ORM::for_table('Auth') 11 ->table_alias('p1') 12 ->where("id",$id)->find_one(); 13 var_dump($user->as_array()); 14 } 15}
php
1<?php 2namespace mycontroller; 3 4class IdiormBase 5{ 6 public function __construct(){ 7 $this->initialDB(); 8 } 9 public static function initialDB(){ 10 ORM::configure('mysql:host=localhost:3306;dbname=data1'); 11 ORM::configure('username', 'root'); 12 ORM::configure('password', 'xxxxxxxx'); 13 ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); 14 } 15}
json
1 "autoload": { 2 "psr-4": { 3 4 "myapp\\": "src/", 5 "mycontroller\\": "public/" 6 7 } 8 },
mycontrollerにバインドしたディレクトリのクラスは読めています。
階層は、mycontrollerがpublicにバインドされていて、publicディレクトリの下に、idiormディレクトリがあり、その中に、idiorm.phpがあり、その中にORMクラスが記述されています。
名前空間を使わず、requireをつかった際はうまく呼べていたのですが、どのように記述すべきでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/30 07:40