【发布时间】:2013-03-11 20:21:41
【问题描述】:
我正在尝试在 Laravel 4 (L4) 中使用 http://geotools-php.org/。
我按照说明通过 Composer 下载(并验证了供应商文件夹中的 geotools 存在)。
我将“app/providers/GeoTools.php”添加到我的自动加载类映射中。
以下是内容:
{
"require": {
"laravel/framework": "4.0.*",
"toin0u/geotools": "@stable"
},
"autoload": {
"classmap": [
"app/commands",
... more laravel stuff
"app/providers/GeoTools.php"
]
}
... more laravel stuff
我创建了 /providers/GeoTools.php 文件。
以下是内容:
<?php
use Illuminate\Support\ServiceProvider;
class GeoToolsServiceProvider extends ServiceProvider {
public function register()
{
$this->app->bind('Coordinate', function()
{
return new Geotools\Coordinate;
});
}
}
在我的 app.php 提供程序数组中,我添加了“GeoToolsServiceProvider”。
这是我的问题:
- 显然我做错了什么,应该怎么做。
- 一旦上述代码正确,如何在整个应用程序中正确使用它?
【问题讨论】:
标签: php inversion-of-control ioc-container laravel composer-php