dsw7547 2017-04-20 20:47
浏览 41

如何在Silex中加载定义文件?

I'm new to silex, and I've got a file that creates a few defines. This is its content:

<?php 

namespace Config;

define('DS',DIRECTORY_SEPARATOR); 
define('ROOT',realpath(__DIR__ . '/../..')); 
define('CONFIG',ROOT.DS.'app'.DS.'config');

I'm trying to load it using my composer.json:

{
    "require": {
        "silex/silex": "~2.0",
        "twig/twig": "^1.33",
        "doctrine/dbal": "^2.5",
        "symfony/twig-bridge": "^3.2",
        "boxedcode/silex-knp-menu-service-provider": "^1.0",
        "symfony/form": "^3.2",
        "symfony/validator": "^3.2",
        "symfony/config": "^3.2"
    },
    "autoload": {
        "psr-4": {
            "Models\\": "src/MyApp/Models/",
            "Config\\": "src/MyApp/Config/"
        }
    }
}

The defines file is inside src/MyApp/Config/, so I therefore hoped this line would be enough to load the defines file in my index.php file:

use Config\Defines;

But... it seems not... Can anyone tell me how to load the defines file so that I can use my Config class again?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题