Php 如何使用正确目录中的名称空间创建推进构建模型?

Php 如何使用正确目录中的名称空间创建推进构建模型?,php,namespaces,composer-php,propel,autoload,Php,Namespaces,Composer Php,Propel,Autoload,我的类的默认目录是:app/ 编写器自动加载配置为: { "autoload": { "psr-4": { "App\\": "app/" } } } 在spreep的schema.xml上,我的命名空间是App\Models 我需要这样的结构: /app/ |___Models/ |___App/ |___Models/ |___Base/ |___Map/ |__

我的类的默认目录是:app/

编写器自动加载配置为:

{
    "autoload": {
        "psr-4": { "App\\": "app/" }
    }
}
在spreep的schema.xml上,我的命名空间是App\Models

我需要这样的结构:

/app/
|___Models/
    |___App/
        |___Models/
            |___Base/
            |___Map/
            |___Country.php
            |___CountryQuery.php
            |___User.php
            |___UserQuery.php
/app/
|___Models/
    |___Base/
    |___Map/
    |___Country.php
    |___CountryQuery.php
    |___User.php
    |___UserQuery.php
<?php
return [
    'propel' => [
        'paths' => [
            // The directory where Propel expects to find your `schema.xml` file.
            'schemaDir' => 'database/schemas',

            // The directory where Propel should output generated object model classes.
            'phpDir' => 'app/Models'
        ],
        'generator' => [
            'namespaceAutoPackage' => 'false'
        ]
    ]
];
我尝试了本手册中的所有组合:

有没有不同的方法来解决这个问题

提前感谢。

请查看build.properties文件

你应该有类似的东西:

propel.packageObjectModel               = true
propel.generator.targetPackage          = App\Models
请查看build.properties文件

你应该有类似的东西:

propel.packageObjectModel               = true
propel.generator.targetPackage          = App\Models

以下是一种按要求工作的方法:

composer.json

}
    "autoload": {
        "classmap": ["app/"]
    }
}
。。。告诉Composer自动加载此文件夹中的类

spreep.php.dist

<?php
return [
    'propel' => [
        'paths' => [
            // The directory where Propel expects to find your `schema.xml` file.
            'schemaDir' => 'database/schemas',

            // The directory where Propel should output generated object model classes.
            'phpDir' => 'app'
        ]
    ]
];

以下是一种按要求工作的方法:

composer.json

}
    "autoload": {
        "classmap": ["app/"]
    }
}
。。。告诉Composer自动加载此文件夹中的类

spreep.php.dist

<?php
return [
    'propel' => [
        'paths' => [
            // The directory where Propel expects to find your `schema.xml` file.
            'schemaDir' => 'database/schemas',

            // The directory where Propel should output generated object model classes.
            'phpDir' => 'app'
        ]
    ]
];

必须在schema.xml中更改数据库名称空间,必须将名称空间设置为:


namespace=\app\Models

您必须在schema.xml中更改数据库名称空间,您必须将名称空间设置为:


namespace=\app\Models

您想将generator.namespaceAutoPackage设置为false。然后确保paths.phpDir仍然设置为app/Models,并且在schema.xml文件中,将数据库名称空间设置保持为app\Models


您想将generator.namespaceAutoPackage设置为false。然后确保paths.phpDir仍然设置为app/Models,并且在schema.xml文件中,将数据库名称空间设置保持为app\Models


问题中指定的配置看起来是正确的,但缺少一点,这使它在我的案例中起作用:将namespaceAutoPackage设置为false。对于问题的php配置文件,如下所示:

/app/
|___Models/
    |___App/
        |___Models/
            |___Base/
            |___Map/
            |___Country.php
            |___CountryQuery.php
            |___User.php
            |___UserQuery.php
/app/
|___Models/
    |___Base/
    |___Map/
    |___Country.php
    |___CountryQuery.php
    |___User.php
    |___UserQuery.php
<?php
return [
    'propel' => [
        'paths' => [
            // The directory where Propel expects to find your `schema.xml` file.
            'schemaDir' => 'database/schemas',

            // The directory where Propel should output generated object model classes.
            'phpDir' => 'app/Models'
        ],
        'generator' => [
            'namespaceAutoPackage' => 'false'
        ]
    ]
];

问题中指定的配置看起来是正确的,但缺少一点,这使它在我的案例中起作用:将namespaceAutoPackage设置为false。对于问题的php配置文件,如下所示:

/app/
|___Models/
    |___App/
        |___Models/
            |___Base/
            |___Map/
            |___Country.php
            |___CountryQuery.php
            |___User.php
            |___UserQuery.php
/app/
|___Models/
    |___Base/
    |___Map/
    |___Country.php
    |___CountryQuery.php
    |___User.php
    |___UserQuery.php
<?php
return [
    'propel' => [
        'paths' => [
            // The directory where Propel expects to find your `schema.xml` file.
            'schemaDir' => 'database/schemas',

            // The directory where Propel should output generated object model classes.
            'phpDir' => 'app/Models'
        ],
        'generator' => [
            'namespaceAutoPackage' => 'false'
        ]
    ]
];

注意\-根名称空间注意\-根名称空间