小编pup*_*upa的帖子

检查laravel的blade指令中是否存在变量

我正在尝试创建刀片指令,如果变量未定义,则返回变量(如果变量定义)或echo"无数据".

这是我的代码AppServiceProvider.php:

<?php

namespace App\Providers;

use Blade;
use Illuminate\Support\ServiceProvider;


class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Blade::directive('p', function($ex) {
            error_log(print_r($ex,true));
            return '<?php $defined_vars = get_defined_vars(); if(array_key_exists(\''. $ex .'\', $defined_vars) ): echo ' . $ex . ' ; else: echo \'no data\'; endif;?>';
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的index.blade.php:

<p class="lead">@p($myvar)</p> …
Run Code Online (Sandbox Code Playgroud)

php directive undefined laravel laravel-5.2

22
推荐指数
9
解决办法
5万
查看次数

Laravel composer install挂起"安装依赖项"并占用大量资源(CPU,DISK)

问题1:

我尝试在我的服务器上安装laravel 4(Ubuntu 12.04,nginx,php5-fpm),但安装挂起:

# composer install --verbose
Loading composer repositories with package information
Installing dependencies (including require-dev)
Run Code Online (Sandbox Code Playgroud)

- 没有错误,没有任何错误,它只是挂起而且就是这样.我尝试使用安装composer create-project laravel/laravel --prefer-dist ......结果非常相似:

Installing laravel/laravel (v4.0.9)
- Installing laravel/laravel (v4.0.9)
Loading from cache

Created project in /var/www/laravel/ex2/laravel
Loading composer repositories with package information
Installing dependencies (including require-dev)
Run Code Online (Sandbox Code Playgroud)

我找不到任何想法/解决方案.

有谁能请告诉我这是什么问题,我该如何解决?

问题2:

@ antonio-carlos-ribeiro是对的,我只需要等待.但现在我又遇到了另一个问题:

安装需要30多分钟!而且很多资源(CPU和磁盘使用)......令人难以置信的资源量.以下是CPU和DISK读/写的图表: 磁盘读/写和CPU使用率 我想这不是正常行为.有什么想法发生了什么?

谢谢!

php installation composer-php ubuntu-12.04 laravel-4

10
推荐指数
2
解决办法
1万
查看次数

Laravel 5:如何将数据重定向到外部资源表单控制器

我想将用户发送到支付门。通常它可以通过这种形式制作:

<form method="post" action="https://demo.moneta.ru/assistant.htm">
    <input type="hidden" name="MNT_ID" value="12345678">
    <input type="hidden" name="MNT_TRANSACTION_ID" value="000001">
    <input type="hidden" name="MNT_CURRENCY_CODE" value="USD">
    <input type="hidden" name="MNT_AMOUNT" value="123.45">
    <input type="submit" value="Pay">
</form>
Run Code Online (Sandbox Code Playgroud)

用户按“支付”并重定向到支付门。

但我想实现这个工作流程:

  1. 用户输入送货信息、付款方式等。
  2. 之后,他按“付款”,然后
  3. 首先,我想存储数据(我在控制器中存储)...
  4. ...之后我想将用户重定向到付款门。(这对我来说不清楚)

问题是:如何将用户从控制器重定向到外部资源(方法应该是 POST,我需要发送一些数据,例如 MNT_ID 等(参见上面的表单示例)?

php payment redirect payment-gateway laravel-5

7
推荐指数
1
解决办法
6714
查看次数

yii2 无法验证您提交的数据

我使用 nginx、PHP 5.5.14、php-fpm、yii2、mac os。

我更改了 yii 配置以将会话存储在数据库中(postgress,用户是超级用户)。这是在我的配置中:

  'session' => [
        'class' => 'yii\web\DbSession',
        'sessionTable' => 'session',
    ],
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试注册新用户时,出现此错误:

Bad Request (#400)
Unable to verify your data submission
Run Code Online (Sandbox Code Playgroud)

这是日志的一部分:

10  17:25:57.434    info    yii\db\Command::query   SELECT "data" FROM "session" WHERE "expire">1425993957 AND "id"='cfg9sutufqchr1tdose4cack15'
/Users/pupadupa/Dev/www/mint-office-web/components/Controller.php (41)
11  17:25:57.442    info    yii\web\Session::open   Session started
/Users/pupadupa/Dev/www/mint-office-web/components/Controller.php (41)
12  17:25:57.450    error   yii\web\HttpException:400   exception 'yii\web\BadRequestHttpException' with message '?? ??????? ????????? ?????????? ??????.' in /Users/pupadupa/Dev/www/mint-office-web/vendor/yiisoft/yii2/web/Controller.php:110
Stack trace:
#0 /Users/pupadupa/Dev/www/mint-office-web/components/Controller.php(41): yii\web\Controller->beforeAction(Object(app\controllers\user\RegistrationAction))
#1 /Users/pupadupa/Dev/www/mint-office-web/vendor/yiisoft/yii2/base/Controller.php(149): app\components\Controller->beforeAction(Object(app\controllers\user\RegistrationAction))
#2 /Users/pupadupa/Dev/www/mint-office-web/vendor/yiisoft/yii2/base/Module.php(455): yii\base\Controller->runAction('registration', Array)
#3 /Users/pupadupa/Dev/www/mint-office-web/vendor/yiisoft/yii2/web/Application.php(83): yii\base\Module->runAction('user/registrati...', …
Run Code Online (Sandbox Code Playgroud)

session csrf yii yii2

6
推荐指数
1
解决办法
7447
查看次数

如何在 iOS 9.3+ 上从网页打开 Safari 的设置

在这里我找到了如何在 iOS 中打开设置的解决方案:How to redirect to ios settings in Safari use javascript in ios9

<input type="button" onclick="redirect()" value="Redirect">
<script>
    var redirect = function() {
        window.location.href = "prefs:root=Settings";
    }
</script>
Run Code Online (Sandbox Code Playgroud)

但是此解决方案在我的 iPhone 6s plus 9.3.2(13F69) 上存在一些问题: - 此解决方案不适用于我的特定 iPhone,但适用于 iPhone 6s - 链接prefs:root=Safari无效

所以我有两个问题:

  1. 我怎么能找出为什么这个解决方案在我的特定手机上不起作用?
  2. 如何在“设置”应用中打开 Safari?

javascript iphone safari settings ios

6
推荐指数
1
解决办法
2177
查看次数

在mac osx lion中安装(构建)matplotlib

我安装了pynum和scipy(在osx Lion上使用python 2.7),但当我尝试构建matplotlib时

git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install
Run Code Online (Sandbox Code Playgroud)

我有这些错误:

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Headers/ATSTypes.h:242: error: declaration for parameter ‘FMFontDirectoryFilter’ but no such parameter
src/_macosx.m:5912: error: expected ‘{’ at end of input
lipo: can't open input file: /var/folders/qw/pr2f7vq91b3c3ngkxrrqplm8zkv09r/T//ccAgEklo.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我这是什么问题吗?

PS起初我试图以这种方式安装它:

pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev
Run Code Online (Sandbox Code Playgroud)

但它对我不起作用

python matplotlib osx-lion

5
推荐指数
1
解决办法
6678
查看次数

在R上安装xts软件包时出错

在尝试安装quantmod包时,我从xts包中得到以下错误:

> install.packages("quantmod", repos="http://R-Forge.R-project.org", type="source")
also installing the dependencies ‘xts’, ‘TTR’

?????? URL 'http://R-Forge.R-project.org/src/contrib/xts_0.9.874.tar.gz'
Content type 'application/x-gzip' length 538182 bytes (525 KB)
==================================================
downloaded 525 KB

?????? URL 'http://R-Forge.R-project.org/src/contrib/TTR_0.22-0.1.tar.gz'
Content type 'application/x-gzip' length 276426 bytes (269 KB)
==================================================
downloaded 269 KB

?????? URL 'http://R-Forge.R-project.org/src/contrib/quantmod_0.4-3.tar.gz'
Content type 'application/x-gzip' length 123464 bytes (120 KB)
==================================================
downloaded 120 KB

* installing *source* package ‘xts’ ...
** libs
clang -I/usr/local/Cellar/r/3.2.1/R.framework/Resources/include -DNDEBUG  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I"/usr/local/Cellar/r/3.2.1/R.framework/Versions/3.2/Resources/library/zoo/include"   -fPIC  -g -O2  -c add_class.c -o add_class.o
clang -I/usr/local/Cellar/r/3.2.1/R.framework/Resources/include -DNDEBUG …
Run Code Online (Sandbox Code Playgroud)

r xts quantmod r-package

4
推荐指数
1
解决办法
3409
查看次数