php - Class not found with composer autoload -


i have file structure

/ /app/ /app/logs/ /app/templates/ /app/index.php /public_html/ /public_html/.htaccess /public_html/index.php /vendor /vendor/(all vendor here) 

my vhost pointing /public_html

in app/index.php

namespace app;  class index {} 

composer.json

"autoload": {     "psr-0":     {         "app\\":  "app/"     } } 

yet still showing ( ! ) fatal error: class 'app\index' not found in c:\wamp\www\project\public_html\index.php on line 34

line 34:

new \app\index(); 

using slimframework if matters, can't think wrong

since using psr-0 standard, php looking file app/app/index.php, not exist. note in psr-0, define base directory (app in case) mapped namespace (app) can found. however, file structure within base directory should match qualified class names. class app\foobar should in file app/app/foobar.php. note app base directory, , app directory contains subdirectories , php files namespace.

since not case in application (and because psr-0 has been deprecated), should (as did) use psr-4, new autoloading standard, instead. in psr-4, can directly map namespace directory. in case, have mapped app namespace app directory, php open app/index.php file if need use app\index class.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

android - Inheriting from Theme.AppCompat* -