자동 로드
프로젝트에 자동 로드가 구현되어 있지 않다면, composer를 이용해 생성할 수 있습니다. 단계는 다음과 같습니다.
1. composer.json 수정
composer.json의 autoload.psr-4에 "" : "./"를 추가합니다. 예를 들어,
{
"require": {
"workerman/workerman" : "^v4.0.0"
},
"autoload": {
"psr-4": {
"" : "./"
}
}
}
2. autoload.php 생성
composer dumpautoload를 실행합니다.
3. autoload.php 로드
프로젝트의 start.php 헤더에 vendor/autoload.php를 로드합니다. 예를 들어,
<?php
require_once __DIR__ . '/vendor/autoload.php';
4. workerman 재시작
php start.php restart