class - Referencing a custom composer package in Slim PHP -


i'm trying figure out how reference custom class using composer

my composer.json file looks this:

{     "name": "adtools_api",     "repositories": [         {             "type": "package",             "package": {                 "name": "qz/adtools_middleware",                 "version": "dev-master",                 "source": {                     "url": "repo-name",                     "type": "git",                     "reference": "master"                 }             }         }     ],    "require": {        "slim/slim": "2.*",        "qz/adtools_middleware": "src/"    } } 

and folder structure looks this:

app     routes     vendor         composer         qz             adtools_middleware                 src                     hello-world.php         slim     composer.json     index.php 

i'm trying reference hello-world.php file looks this:

<?php  namespace helloworld;  class sayhello {     public static function world()     {         return 'hello world, composer!';     } }  ?> 

in index.php file i'm trying reference class this:

$hello = new helloworld\sayhello(); 

but getting error telling me "fatal error: class 'helloworld\sayhello' not found in..."

if can point me in right direction great! thank you!

can check autoload inside vendor folder , see if helloworld namespace loaded?

if not, may need add autoload attribute composer.json file, this

{   "autoload": {     "psr-0": {"helloworld": "qz/adtools_middleware/src/"} }, 

to load helloworld namespace in project


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -