我最近一直在询问有关异常和处理异常等问题,最近我在这个问题上最好地解释了这个问题.我现在的问题是如何使用
set_exception_handler();
Run Code Online (Sandbox Code Playgroud)
在一个类中设置php中的错误处理类,当抛出错误时,由此类处理.正如定义所述:
如果未在try/catch块中捕获异常,则设置缺省异常处理程序.调用exception_handler后,执行将停止.
我以为我可以这样做:
class Test{
public function __construct(){
set_exception_handler('exception');
}
public function exception($exception){
echo $exception->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud)
但问题是,如果用户正在设置应用程序或使用应用程序中的任何API,则必须执行以下操作: new Test();
那么我怎么能编写一个异常处理程序类:
我展示的方式是我能想到的唯一方法.
我在我的网站上实现了引导菜单.问题是如果我切换页面菜单变得没有响应,请接受"徽标部分",它将我带回主页.如果我刷新页面,下拉菜单会再次运行.我不知道为什么.
我application.js看起来像:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require moment
//= require react
//= require react_ujs
//= require writer/react/panel
Run Code Online (Sandbox Code Playgroud)
我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'pg'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'therubyracer'
gem 'figaro'
gem 'responders', '~> 2.0'
gem 'active_model_serializers', github: 'rails-api/active_model_serializers', branch: '0-8-stable'
gem 'xaaron', '0.6.11', :git => 'git@github.com:AdamKyle/Xaaron.git', :tag => '0.6.11'
# Debug
gem 'pry', require: 'pry'
gem 'pry-rails'
# Assets & Asset Management …Run Code Online (Sandbox Code Playgroud) 所以我不确定这里的问题是什么,或者这个类是如何加载的。但我的模型(或者他们实际所说的实体)看起来像这样:
<?php
namespace ImageUploader\Models;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="users")
* @UniqueEntity(fields="userName")
* @UniqueEntity(fields="email")
*/
class User {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
protected $id;
/**
* @ORM\Column(type="string", length=32, nullable=false)
* @Assert\NotBlank()
*/
protected $firstName;
/**
* @ORM\Column(type="string", length=32, nullable=false)
* @Assert\NotBlank()
*/
protected $lastName;
/**
* @ORM\Column(type="string", length=100, unique=true, nullable=false)
* @Assert\NotBlank(
* message = "Username cannot be blank"
* )
*/
protected $userName;
/**
* @ORM\Column(type="string", …Run Code Online (Sandbox Code Playgroud) 所以我写了以下路线:
Route::get('/login', function() {
return View::make('login.form');
});
Run Code Online (Sandbox Code Playgroud)
这是观点:
@extends('layouts.master')
@section('content')
<div class="form-section">
{{ Form::open(
array(
'url' => 'login-submit',
'method' => 'POST'
)
)
}}
{{ Form::submit('Authorize With AisisPlatform') }}
{{ Form::close() }}
@stop
Run Code Online (Sandbox Code Playgroud)
这正是我在查看页面时看到的内容:
<form method="POST" action="http://app-response.tracking/login-submit" accept-charset="UTF-8"><input name="_token" type="hidden" value="7xHzX20h1RZBnkTP2CRraZVsAfSQIfVP61mBiFtN"> <input type="submit" value="Authorize With AisisPlatform"> </form>
Run Code Online (Sandbox Code Playgroud)
嗯.....表格不应该好......和实际形式?为什么它将html呈现为字符串?如何使其呈现实际的表单提交按钮?
所以我按照我的流浪盒子的这些说明,一切似乎都很顺利,我的意思是它正在运行。它已经配置了它的服务器 ID 和服务器令牌。
然后我按照同一页面上的说明安装了 PHP Probe,并在完成后重新启动了 apache2。然后我做了composer require
blackfire/php-sdk,最后在我的代码中我做了:
$probe = $blackfire->createProbe();
// some PHP code you want to profile
$blackfire->endProbe($probe);
dd('End here.'); // Laravels die and dump function.
Run Code Online (Sandbox Code Playgroud)
所以据我所知,我做的一切都是正确的。然后,在我的控制台中,我做了:
vagrant@scotchbox:/var/www$ php artisan fetch_eve_online_region_type_history_information
[Blackfire\Exception\ApiException]
401: while calling GET https://blackfire.io/api/v1/collab-tokens [context: NULL] [headers: array (
0 => 'Authorization: Basic xxxxxx=',
1 => 'X-Blackfire-User-Agent: Blackfire PHP SDK/1.0',
)]
// where xxxx is some kind of authentication token that looks different from what I gave as my server …Run Code Online (Sandbox Code Playgroud) 如果我有一个usermodel和我定义:
"events": {
"type": [
"Object"
]
},
Run Code Online (Sandbox Code Playgroud)
我是否需要在其中定义任何其他内容,usermodel.js以便能够发布以下内容:[{name: 'sample', ...}, ...]到用户表的事件列?
我问,因为如果我从.json应用程序编译中移除此特定定义并且数据库迁移,但是在其中,应用程序编译但数据库指出用户存在问题findByid.我的调试已经缩小到这个特定的代码集.
所以我想知道什么会导致它,以便完整 jquery 日历的所有事件都会显示在左上角。即使有,它也会在选项卡中显示您有“星期日”,而可能会安排在下星期一
我正在使用php方法getTraceAsString(),这将抛出我的错误消息,如:
#0 /var/www/wordpress/wp-content/themes/Aisis-Framework/AisisCore/Template/Builder.php(147): AisisCore_Template_Builder->_render_template_array(Array, 'navigation') #1 /var/www/wordpress/wp-content/themes/Aisis-Framework/index.php(3): AisisCore_Template_Builder->render_view('navigation') #2 /var/www/wordpress/wp-includes/template-loader.php(47): include('/var/www/wordpr...') #3 /var/www/wordpress/wp-blog-header.php(16): require_once('/var/www/wordpr...') #4 /var/www/wordpress/index.php(17): require('/var/www/wordpr...') #5 {main}
Run Code Online (Sandbox Code Playgroud)
你可以看到一个巨大的字符串.他们提供的示例将跟踪打印为单独的行.为了得到这个,我有什么必须做的吗?
所以我有以下示例字符串:'Sam's Place'我想将其更改为"Sam's Place".是否有一种简单的方法来使用单引号操纵使用双引号?重要的是保持字符串中的单引号.
我试过了:
var samsPlaceName = samsPlace.replace(/'/g, '"');
// And:
JSON.stringify(samsPlace);
// Both give me:
'Sam"s Place'
'"Sam's Place"'
Run Code Online (Sandbox Code Playgroud)
我想要的只是将字符串更改为:"Sam's Place".
可以这样做吗?
因此,在任何人关闭此功能之前,我将在这里参考答案并提出问题。
所以我的问题是我想要对 laravel 进行强密码验证,包括 10 个字符、数字、大写小写等等。
我找到了:https : //stackoverflow.com/a/31549892/1270259
问题是,这个正则表达式看起来不对:
/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/
Run Code Online (Sandbox Code Playgroud)
由于我不擅长正则表达式,我想我会问如何修复它以使其验证:
我觉得他们的答案很接近。当这是针对 github 操作运行时,返回的错误是preg_match(): Compilation failed: escape sequence is invalid in character class at offset 46.
我也有任何想法如何让 Laravel 7 工作以匹配上述约束?
php ×6
javascript ×3
exception ×2
jquery ×2
blackfire ×1
blade ×1
css ×1
doctrine-orm ×1
forms ×1
fullcalendar ×1
laravel ×1
laravel-5 ×1
laravel-7 ×1
loopback ×1
loopbackjs ×1
phpunit ×1
regex ×1
stack-trace ×1
string ×1