1. Go to this page and download the library: Download doctordanila/script-doc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
doctordanila / script-doc example snippets
DoctorDanila\ScriptDoc\Include\Controller;
$docController = (new Controller())
->setProjectName('Мой проект')
->setDocsDir(__DIR__ . '/../docs') // путь к папке с .md файлами
->setRoutePrefix('/docs') // URL-префикс
->setSwaggerPath('/api/docs'); // ссылка на Swagger (опционально)
$docController->handleRequest();
namespace app\modules\docs;
use yii\base\Module as BaseModule;
use DoctorDanila\ScriptDoc\Include\Controller;
class Module extends BaseModule
{
public $controllerNamespace = 'app\modules\docs\controllers';
public $defaultRoute = 'default/index';
public function init()
{
parent::init();
// Дополнительная настройка модуля
}
}
namespace app\modules\docs\controllers;
use yii\web\Controller as YiiController;
use DoctorDanila\ScriptDoc\Include\Controller as DocController;
class DefaultController extends YiiController
{
public function actionIndex()
{
$doc = new DocController();
$doc->setProjectName('Мой проект')
->setDocsDir(\Yii::getAlias('@app/docs'))
->setRoutePrefix('/docs')
->setSwaggerPath('/api/docs');
$doc->handleRequest(); // сам завершит выполнение
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use DoctorDanila\ScriptDoc\Include\Controller;
class DocServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(Controller::class, function ($app) {
return (new Controller())
->setProjectName(config('app.name'))
->setDocsDir(base_path('docs'))
->setRoutePrefix('/docs')
->setSwaggerPath('/api/docs');
});
}
public function boot()
{
$controller = $this->app->make(Controller::class);
$controller->handleRequest();
}
}
App\Providers\DocServiceProvider::class,
Route::any('/docs/{any?}', function () {
// Обработчик уже перехватит запрос через сервис-провайдер
})->where('any', '.*');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.