php – 使用“Neoxygen / Neoclient”作为ServiceProvider Facade进入Laravel 5.1
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 使用“Neoxygen / Neoclient”作为ServiceProvider Facade进入Laravel 5.1,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1742字,纯文字阅读大概需要3分钟。
内容图文
![php – 使用“Neoxygen / Neoclient”作为ServiceProvider Facade进入Laravel 5.1](/upload/InfoBanner/zyjiaocheng/766/f729cbf248f241059f43ca65e137a121.jpg)
[编辑]:好的,我在测试期间多次更新了这篇文章,现在它正在运行……我在下面给出了正确的代码… [/ EDIT]
从今天早上起,我正在尝试使用“Neoxygen / Neoclient”作为ServiceProvider和Facade进入Laravel 5.1的全新安装
为此,我在composer.json中需要“neoxygen / neoclient”:“^ 3.0”
然后我在“app / Providers”中创建了一个名为“NeoClientServiceProvider”的新ServiceProvider.
在其登记方法;我已经实例化了连接:
public function register()
{
$this->app->singleton('neoclient', function ($app) {
return ClientBuilder::create()
->addConnection('default', 'http', env('NEO4J_HOST'), intval(env('NEO4J_PORT')), true, env('NEO4J_USER'), env('NEO4J_PASSWORD'))
->setDefaultTimeout( intval(env('NEO4J_TIMEOUT')) )
->setAutoFormatResponse(true)
->build();
});
}
接下来,我通过在我的提供程序中包含Full Class并设置别名,在“config / app.php”中注册了ServiceProvider:
'providers' => [
...
App\Providers\NeoClientServiceProvider::class
...
],
'aliases' => [
...
'NeoClient' => App\NeoClient::class
...
]
我还创建了一个NeoClient类,它扩展了Facade,如下所示:
<?php namespace App;
use \Illuminate\Support\Facades\Facade;
class NeoClient extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'neoclient'; }
}
最后我有一个像这样的控制器:
<?php namespace App\Http\Controllers;
use NeoClient;
class GenreController extends Controller
{
public function __construct()
{
// needed authentication
//$this->middleware('oauth');
}
public function create()
{
$data = NeoClient::sendCypherQuery("MATCH (g:Genre) RETURN COUNT(g) AS total")->getRows();
return response()->json($data);
}
}
PS:我知道“NeoEloquent”存在,但我不想使用这个……
弗雷德.
解决方法:
当然你可以!这是客户的链接:
https://github.com/graphaware/neo4j-php-client
内容总结
以上是互联网集市为您收集整理的php – 使用“Neoxygen / Neoclient”作为ServiceProvider Facade进入Laravel 5.1全部内容,希望文章能够帮你解决php – 使用“Neoxygen / Neoclient”作为ServiceProvider Facade进入Laravel 5.1所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。