一个简单的Web应用程序框架

dev-main 2023-01-03 00:56 UTC

This package is auto-updated.

Last update: 2024-08-30 01:12:33 UTC


README

从Mini到Wumbo!

Wumbo是一个用于在PHP中构建简单Web应用程序的框架。

安装

通过Composer安装

如果您系统上还没有安装Composer,请安装Composer

要安装库,运行以下命令,您将获得最新版本

$ composer require secondtruth/wumbo:dev-main

用法

创建一个名为public/index.php的新文件,并添加一些代码,如下所示

<?php
namespace Secondtruth\SampleWebsite;

use DI\Container;
use Secondtruth\Wumbo\Application;
use Secondtruth\Wumbo\View\Templating\TemplatingEngineInterface;
use Secondtruth\Wumbo\View\Templating\TwigEngine;
use Secondtruth\Wumbo\Loader\Routes\MultisiteRoutesLoader;

define('APP_ROOT', realpath(__DIR__ . '/..'));
define('CONFIG_DIR', APP_ROOT . '/config');

require APP_ROOT . '/vendor/autoload.php';

// Create a DI container to inject the dependencies you want to use.
// We use the PHP-DI container here, but you can use any other PSR-11 compatible container as well.
// In this example, we set Twig as our template engine.
$container = new Container();
$container->set(TemplatingEngineInterface::class, TwigEngine::create(APP_ROOT . '/resources/views', [
    'cache' => APP_ROOT . '/var/cache/twig',
]));

// Create and set up a routes loader and give it to the application.
$routesLoader = new MultisiteRoutesLoader(CONFIG_DIR);
$routesLoader->registerSite('example.com'); // Give the domain of your website

// Create a new Application instance and set routes loader and container.
$app = new Application($routesLoader, $container);
$app->setCachePath(APP_ROOT . '/var/cache');

$app->run();

作者、致谢和许可证

该项目由Christian Neff (@secondtruth)创建,并使用MIT许可证。

感谢所有其他贡献者