laravel

Call Mongodb stored function from PHP7

浪子不回头ぞ 提交于 2021-02-18 03:17:22
问题 Below is my mongodb function that is stored in Mongodb. db.system.js.save( { _id: "echoFunction", value : function(x) { return x; } } ) I can call this function in mongo using below query : db.loadServerScripts(); echoFunction(3); Now i want to call this function from PHP 7. and also help with laravel. 回答1: You can use following code snippet from laravel to execute your mongoDB function. $cursor = DB::connection('mongodb')->command(array('eval' => 'echoFunction("4")')); $data = $cursor-

laravel 实现阿里云oss文件上传

巧了我就是萌 提交于 2021-02-18 01:14:55
1、定义路由 // 阿里云文件储存 Route::group(['prefix'=>'aliyun'], function (){ Route ::get('sign', 'AliyunController@sign' ); }); 2、编写 controller 层 /* * * 返回OSS的签名验证 * @return JSON 签名信息 */ public function sign(Request $request ) { // 初始化一下必要的请求数据 $id = 'xxx'; // AccessKeyId $key = 'xxx'; // AccessKeySecret $host = '//xxx.oss-cn-shenzhen.aliyuncs.com'; // OSS库地址 $cdn_host = "//img.xxx.com"; // 真实的访问地址 $dir = 'test/'; // 上传目录设置 $callbackUrl = url('upload/callback'); // 上传回调的地址 //上传回调的参数,callbackUrl地址,callbackBody回调接收的参数,callbackBodyType通过POST调用的回调函数,所以要设置这个头 $callback_param = array ( 'callbackUrl' =>

How to create database schema (table) in Laravel?

不问归期 提交于 2021-02-18 00:50:30
问题 I'm new to Laravel.I'm trying to create database in Laravel. I tried in console with: Schema::create But it's giving 'command not found'. What should I install or how to create database? 回答1: First you have to set database name,username and password in database.php in config folder.it look like 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => storage_path('database.sqlite'), 'prefix' => '', ], 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'),

How to create database schema (table) in Laravel?

空扰寡人 提交于 2021-02-18 00:50:28
问题 I'm new to Laravel.I'm trying to create database in Laravel. I tried in console with: Schema::create But it's giving 'command not found'. What should I install or how to create database? 回答1: First you have to set database name,username and password in database.php in config folder.it look like 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'database' => storage_path('database.sqlite'), 'prefix' => '', ], 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'),

laravel使用阿里云OSS上传图片

只谈情不闲聊 提交于 2021-02-18 00:35:53
需要自己注册阿里云账号并且开通oss服务,建立Bucket存储空间,此步骤不做演示 一、composer安装:使用composer在项目根目录执行以下命令 composer require johnlui/aliyun-oss:~2.0 二、构建 Service 文件 需要自己手动建立 app/services/OSS.php 修改配置信息,改为自己的阿里云AccessKeyId AccessKeySecret 注意OSS.php 文件中 private $city = ‘青岛’; 所对应的城市,要根据自己OSS相对应的地区所选择 如何查看自己的OSS地区,请到阿里云OSS中查看,修改错误会导致无法连接到阿里云OSS服务器 OSS.php文件: <? php namespace App\services; use JohnLui\AliyunOSS; use Exception ; use DateTime; class OSS { /* 城市名称: * * 经典网络下可选:杭州、上海、青岛、北京、张家口、深圳、香港、硅谷、弗吉尼亚、新加坡、悉尼、日本、法兰克福、迪拜 * VPC 网络下可选:杭州、上海、青岛、北京、张家口、深圳、硅谷、弗吉尼亚、新加坡、悉尼、日本、法兰克福、迪拜 */ private $city = '' ; // 经典网络 or VPC private

laravel环境搭建

故事扮演 提交于 2021-02-17 23:05:16
安装Composer 安装Composer 修改 composer 的全局配置文件 composer config -g repo.packagist composer https://packagist.phpcomposer.com 下载项目文件 composer create-project laravel/laravel learnlaravel5 5.2.31 启动项目 cd learnlaravel5/public , php -S 0.0.0.0:1024 开启注册登录功能 php artisan make:auth 开启mysql服务 sudo /usr/local/mysql/support-files/mysql.server start 来源: oschina 链接: https://my.oschina.net/u/2861166/blog/811563

搭建laravel环境

百般思念 提交于 2021-02-17 23:04:51
1. 下载laravel代码 wget https://github.com/laravel/laravel/archive/master.zip 2. 解压以后,进入laravel目录 3. 下载composer curl -sS https://getcomposer.org/installer | php 确定composer是否安装完成 php composer.phar 4. 在laravel目录安装composer php composer.phar install 5. 通过nginx配置b本地虚拟主机 详情见:http://my.oschina.net/meowmeow/blog/200865 6. 重启nginx服务器,浏览器访问 http://laravel.cc/ 来源: oschina 链接: https://my.oschina.net/u/266279/blog/207476

Laravel connect to a SQL Server 2008 named instance

回眸只為那壹抹淺笑 提交于 2021-02-17 22:55:35
问题 I am trying to connect an SQL server from an Ubuntu machine, everythings works great except for named instances: this works 'data' => array( 'driver' => 'sqlsrv', 'host' => 'xxxx', 'port' => 1433, 'database' => 'db', 'username' => 'user', 'password' => 'pwd', 'prefix' => '', ), this doesn't 'data' => array( 'driver' => 'sqlsrv', 'host' => 'yyyy\NAMEDINSTANCE', 'port' => 1433, 'database' => 'db', 'username' => 'user', 'password' => 'pwd', 'prefix' => '', ), I always end up with this error:

phpspec and laravel setup

跟風遠走 提交于 2021-02-17 20:55:17
问题 I am setting up a new Laravel project and integrating PHPSpec. I am having trouble finding a good working example of the phpspec.yml file that would work neatly with Laravel. In a similar way to RSpec in Rails. My desired folder structure would be as follows spec/ models/ controllers/ app/ models/ controllers/ My phpspec.yml currently looks like this: suites: controller_suite: namespace: Controller spec_path: 'spec/controllers' src_path: 'app/controllers' model_suite: namespace: Model spec

Laravel | How to perform search with multiple attributes

你离开我真会死。 提交于 2021-02-17 07:22:05
问题 I am creating property website and i am doing search with number of attributes, but the problem is that in search controller i have very large code and its very difficult to handle, is there any other solution exist in laravel? $list_property = Listing_property::where([ ['property_type', $request['property_type']], ['city', $request['city']], ['location', $request['location']], ['property_area_type', $request['property_area_type']], ['property_size', $request['property_size']], ['price', $min