$mkdir App
$mkdir App/Data
$code App/Data/Database.php
App/Data/Database.php
<?php
namespace App\Data;
class Database {
public function __construct()
{
echo "the init\n";
}
public function sayHi()
{
echo "create database\n";
}
}
$code composer.json
{
"autoload": {
"psr-4": {
"App\\":"App/"
}
}
}
$code index.php
<?php
require __DIR__ . '/vendor/autoload.php';
use App\Data\Database;
$obj = new Database();
echo $obj->sayHi();
?>
$composer dump
$php index.php
output
the init
create database
Top comments (0)