我知道这里有大约10个这样的问题,但没有一个完全适合我.
完成的步骤:
php信息结果:
memcache.allow_failover 1 1
memcache.chunk_size 8192 8192
memcache.default_port 11211 11211
memcache.default_timeout_ms 1000 1000
memcache.hash_function crc32 crc32
memcache.hash_strategy standard standard
memcache.max_failover_attempts 20 20
Run Code Online (Sandbox Code Playgroud)
memcached-tool结果:
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 0
bytes_read 14
bytes_written 1096
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 0
cmd_get 0
cmd_set 0
cmd_touch 0
conn_yields 0
connection_structures 6
crawler_reclaimed 0
curr_connections 5
curr_items 0
decr_hits 0
decr_misses 0
delete_hits 0
delete_misses 0
evicted_unfetched 0
evictions 0
expired_unfetched 0 …Run Code Online (Sandbox Code Playgroud) 所以,我一直在构建一个laravel 5.1 API,经过几个月的工作,我突然意识到我应该一直使用Lumen.
有没有办法将laravel应用程序转换为流明应用程序?
所以我正在尝试在生产中部署我的rails应用程序.当我进入页面时,我收到500错误.当我转到我的错误日志时,我收到以下错误:
Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`)
Run Code Online (Sandbox Code Playgroud)
我正在运行Rails 4.1,我的config/secrets.yml看起来像这样:
development:
secret_key_base: <development key>
test:
secret_key_base: <test key>
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Run Code Online (Sandbox Code Playgroud)
我运行rake secret获取密钥并将导出放入我的bash_profile并获取它.我运行了rake资产:预编译成功.然而,我仍然一直在犯这个错误.有任何想法吗?
更新:我试图更新提供的错误消息,以提供更好的信息....并且消息没有更新.然后我尝试将密钥直接添加到yml文件,而不是使用环境变量,仍然没有骰子.我在hostmonster上运行,所以我无法重新启动服务器.....但有些东西告诉我需要做什么...
更新2:彻夜难眠后,这个问题似乎不再是问题.它一定是某种缓存.现在我的问题是它试图使用我几天前为我的数据库更改的旧配置.如果我弄清楚如何使缓存无效,我将在此处发布并将其标记为答案.如果其他人知道该怎么做,请告诉我,我会将其标记为答案.我使用HostMonster作为我的托管,并按照他们在他们的网站上的步骤来托管我的rails应用程序.
所以我跟着这个,我正在尝试运行他的第一个php示例.我收到以下错误:
PHP警告:require_once(
Zend/Http/Header/HeaderValue.php):无法打开流:第45行/opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Http/Client.php中没有此类文件或目录
我检查过,文件实际上并不存在.所以我从最小的1.12下载中添加了它.它然后说不Zend/Xml/Security.php存在所以我添加它.
现在我收到以下错误:
PHP Notice: Undefined offset: 1 in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/ClientLogin.php on line 150
PHP Stack trace:
PHP 1. {main}() /opt2/sites/gdataApi/test.php:0
PHP 2. Google_Spreadsheet->__construct() /opt2/sites/gdataApi/test.php:11
PHP 3. Google_Spreadsheet->login()/opt2/sites/gdataApi/Google_Spreadsheet.php:40
PHP 4. Zend_Gdata_ClientLogin::getHttpClient() /opt2/sites/gdataApi/Google_Spreadsheet.php:223
PHP Notice: Undefined variable: php_errormsg in /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php on line 834
PHP Stack trace:
PHP 1. {main}() /opt2/sites/gdataApi/test.php:0
PHP 2. Google_Spreadsheet->addRow() /opt2/sites/gdataApi/test.php:24
PHP 3. Google_Spreadsheet->getSpreadsheetId() /opt2/sites/gdataApi/Google_Spreadsheet.php:62
PHP 4. Zend_Gdata_Spreadsheets->getSpreadsheetFeed() /opt2/sites/gdataApi/Google_Spreadsheet.php:252
PHP 5. Zend_Gdata->getFeed() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/Spreadsheets.php:150
PHP 6. Zend_Gdata_App->getFeed() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata.php:162
PHP 7. Zend_Gdata_App->importUrl() /opt2/sites/gdataApi/ZendGdata-1.12.13/library/Zend/Gdata/App.php:213
PHP …Run Code Online (Sandbox Code Playgroud) 所以我有一个名为VIP的模型,它有很多与之相关的信息.因此,当我们去路线时,vip/{id}我会返回大部分信息.但是,当我去的时候,vips/{per-page}我不想返回所有数据,因为API会以指数方式减速.相反,我宁愿只返回一些更基本的东西.
为了做到这一点,我有一个Transformer,在顶部创建基本响应,然后进入下面的一些更复杂的关联,然后返回所有.我希望向变换器发送某种类型的标志,如果为真则只返回基本响应.但是,我正在使用分形,似乎无法找到一种能够将此标志发送到变压器的方法.
VipsController @ index:
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request, $perPage = 15)
{
$page = $request->input('page');
$vip = Cache::tags(['vips'])->remember("vip.index.$perPage.$page", 60, function() use ($perPage){
Log::info('getting data from the database');
return $this->vip->paginate($perPage, ['*'], ['gender','status','local','jobClass','nonMember','initiationDate','pensioner']);
});
return $this->fractal->paginatedCollection($vip, new VipTransformer());
}
Run Code Online (Sandbox Code Playgroud)
VipTransformer @转换:
public function transform(Vip $vip)
{
$response = [
'id' => $vip->vip_id,
'first_name' => isset($vip->first_name) ? $vip->first_name : '',
'last_name' => isset($vip->last_name) ? $vip->last_name …Run Code Online (Sandbox Code Playgroud) 所以我做了很多计算,最后我需要将速率保存到表中的现有行.
我拥有的数组将类似于以下内容:
[
<model_id> => [
'rate' => <some rate>
]
<model_id_2> => [
'rate' => <some other rate>
]
.....
]
Run Code Online (Sandbox Code Playgroud)
现在显然我可以预先通过这个数组并对数组中的每个项目进行更新,但最终我可能会有100个更新调用.有没有办法(通过laravel的雄辩或甚至是原始的SQL查询)通过一次调用来完成所有这些更新?
因此,我正在努力创建我的第一个服务提供商和Laravel的免费Facade.
服务提供者:
<?php namespace Jbm\Providers;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Jbm\Helpers\ReportGenerator;
class ReportGeneratorServiceProvider extends BaseServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind('Jbm\Helpers\Contracts\ReportGeneratorContract', function($app){
return new ReportGenerator();
});
}
/**
* Add the Cors middleware to the router.
*
* @param Kernel $kernel
*/
public function boot(Request $request, …Run Code Online (Sandbox Code Playgroud) 我有一个laravel API.对于那些不知道的人,Laravel使用方法欺骗来处理PUT和DELETE方法,因此它使用_method = [PUT | DELETE]作为PUT或DELETE方法读取POST调用.
我们用Postman测试我们的API.在邮递员中,我可以向服务器发送真正的DELETE和PUT调用,而不必欺骗.到目前为止,这两种方法都运行良好
今天,我们的测试版服务器将允许PUT/DELETE方法,但它从中剥离了身体参数.这只发生在我们的测试版服务器上,这使我相信它是一个服务器问题,但我们的服务器上几个月没有任何变化.它的CentOS 6.8使用Apache和php 7.请求通过然后laravel立即响应,好像没有任何正文参数存在,无论是验证错误还是删除所有内容而不仅仅是某个东西.
所以我正在尝试使用安装 mongodb pecl 扩展sudo pecl install mongodb并获得以下内容:
downloading mongodb-1.1.2.tgz ...
Starting to download mongodb-1.1.2.tgz (642,582 bytes)
....done: 642,582 bytes
349 source files, building
running: phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
building in /var/tmp/pear-build-rootGfSZhI/mongodb-1.1.2
running: /var/tmp/mongodb/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for …Run Code Online (Sandbox Code Playgroud) 如何在控制器之外使用 Laravel Eloquent 模型?我似乎不知道use "*insert class here*"我应该使用什么声明。我有一个帮助类,它将经常使用我的“类别模型”。
这是我正在使用的代码。当我使用类别时它失败:
<?php
namespace Msh\Redirects;
use Illuminate\Support\Facades\Config as Config;
use Illuminate\Support\Facades\Input as Input;
/**
* This is the actual "product class" that generates the 301 redirect url's
*
* This is the product
*
* @author bgarrison
*/
class StorefrontRedirectsGenerator implements RedirectsGenerator {
public function generateUrls() {
// Set the database to the name of the domain
Config::set('database.connections.mysql_tenant.database', Input::get('domain'));
// Grab all the categories
$categories = Category::all();
// Use category information to …Run Code Online (Sandbox Code Playgroud) 所以我有一个带有以下按钮的表单:
<form name="invoiceLine">
<div class="rTableRow">
<div class="rTableCell rTableCellXsm" ng-keyup="keyPress($event)">{{invoice_line.line}}</div>
<div class="rTableCell rTableCellL" >
<datecomponent style="display: inline-block" model="invoice_line.date" elementid="il2" tabindex="'1'"></datecomponent>
</div>
<div class="rTableCell rTableCellXl" ng-keyup="keyPress($event)">
<input id="invLineDesc" style="width: 90%;" type="text" ng-model="invoice_line.description" ng-maxlength="30" tabindex="2">
<span class="redtext">*</span>
<div>{{invoice_line.description.length <= 30 ? 30 - invoice_line.description.length + ' chars remaining' : 'Description too long!' }}</div>
</div>
<div class="rTableCell rTableCellL" ng-keyup="keyPress($event)">
$<input style="width: 50%; margin-left: 5px;" type="text" ng-model="invoice_line.amount" tabindex="3">
</div>
<div class="rTableCell rTableCellL">
<input type="button" class="button {{buttonPrefColor}}" ng-click="add_new_invoice_line()" ng-show="invoiceLine.$dirty" value="Add New" tabindex="4">
<input type="button" class="button {{buttonPrefColor}}" …Run Code Online (Sandbox Code Playgroud) 所以我开发了一个 API,其中一个端点是报告生成器。通常,他们发送报告的名称和其他一些变量,然后使用Laravel-Snappy弹出一个 PDF 。
我也使用JWT-Auth进行身份验证。由于我需要符合 HIPAA 标准,因此我将在每次通话时刷新令牌。对于大多数端点,这很容易,因为我只需将它添加到我的 json 响应的元数据中。
但是,对于报告,他们只返回带有标题的 PDF 以强制下载等。有没有办法让我将 PDF 数据作为 JSON 响应的一部分发送,应用程序命中此 API 将能够使用?我是否可能需要以某种方式加密它,以便它可以通过 json 响应发送?任何关于任何想法的其他想法将不胜感激。
所以我有以下验证:
'birth_date' => 'date_format:Y-m-d|before:deceased_date',
'deceased_date' => 'date_format:Y-m-d|after:birth_date',
Run Code Online (Sandbox Code Playgroud)
问题是这些都不是必填字段。有人可以输入没有birth_date 的死亡日期,反之亦然。目前,如果您发送没有出生日期的已故日期,则after验证失败。有没有办法检查before/after检查其他日期是否已发送?
需要明确的是,这里是验证场景:
只寄一份也可以。我只是想确定,如果他们同时发送两者,它会检查该人是否在出生前没有死亡,反之亦然。