php - How to add a class to Composer for autoloading? -


i have class called class.feed.php, how include composer such when 'vendor/autoload.php' included or required in example index.php, class included?

note, still php newbie.

here's example of using composer.

{   "autoload": {       "psr-0": {"appname": "src/"}   } } 

set structure follows:

 src/    - appname/  vendor/  composer.json  index.php 

place classes inside appname folder, use namespace class relative src folder.

classes should have same filename class name starting capital, example class called demo in appname:

<?php namespace appname;  class demo {     public function __construct(){     echo 'hi';    } } 

then in root create index.php include autoload vendor once composer has been installed.

to use class call namespace followed class name

<?php require('vendor/autoload.php');  $demo = new \appname\demo(); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -