我最近为Yii2基本应用程序模板运行了最新的作曲家安装.
但是运行php composer.phar install
抛出了这个异常:
类Fxp\Composer\AssetPlugin\Repository\NpmRepository不存在
"yiisoft/yii2-composer"插件需要composer-plugin-api 1.0.0,这个WIL L在未来中断,应该尽快修复(例如需要^ 1.0).
[ReflectionException]类Fxp\Composer\AssetPlugin\Repository\NpmRepository不存在
[ErrorException]
声明Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository :: w hatProvides()应该与Composer\Repository\ComposerRepository :: whatProvides(Composer\DependencyResolver\Pool $ pool,$ name,$ bypassFilters = fal se)兼容
这是我的composer.json:
{
"name": "yiisoft/yii2-app-basic",
"description": "Yii 2 Basic Project Template",
"keywords": ["yii2", "framework", "basic", "project template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*", …
Run Code Online (Sandbox Code Playgroud) $ array的var_dump返回:
array (size=3)
0 =>
object(frontend\models\Notifications)[101]
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=5)
'id' => int 1
'created_on' => string '2015-11-12 12:12:15' (length=19)
'user_id' => int 1
'text' => string '2severity level is 2guardian is 5,Student_id 2 created a Level 2 discipline issue in school' (length=91)
'is_seen' => int 0
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=5)
'id' => int 1
'created_on' => string '2015-11-12 12:12:15' (length=19)
'user_id' => int 1
'text' => string '2severity level is 2guardian is 5,Student_id 2 …
Run Code Online (Sandbox Code Playgroud) 请让我断言:这个问题不是这个问题的重复,
在 Laravel 5 中,我尝试安装barryvdh/laravel-debugbar
. 但它没有显示。
我做了以下事情:
安装:
composer require barryvdh/laravel-debugbar
将以下行添加到提供程序部分的 config/app.php
'Barryvdh\Debugbar\ServiceProvider',
在外墙列表中..
'Debugbar' => 'Barryvdh\Debugbar\Facade',
我进一步执行:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
之后,我尝试了所有方法来回答我在本问题开头提到的类似问题。
就像在 中启用调试一样.env
,在 debugbar.php 中启用它,清除配置缓存php artisan config:clear
并再次缓存
php artisan config:cache
还 ..
php artisan view:clear
;
但是调试栏不会出现?
可能是什么原因?
例如,在Yii2框架中,yii\filters\AccessControl
该类init()
从其父类重写一个函数yii\base\Object
.这个Object类又有一个像这样的构造方法:
Class Object implements Configurable {
public function __construct($config = [])
{
if (!empty($config)) {
Yii::configure($this, $config);
}
$this->init(); // calls the method defined below
}
}
// and the definition of this init function ...
public function init()
{
}
Run Code Online (Sandbox Code Playgroud)
现在没有明显的使用编写这样一个空函数,除非你想用它来初始化他/她将来可能需要的一些属性.
但是那个__construct()
方法的用法完全一样!我需要了解这种init()
方法是如何有用的.
要查找在 Laravel 应用程序中定义函数的位置,我正在尝试执行以下操作:
内部App\Http\Controllers
命名空间:
$reflFunc = new ReflectionFunction('function_name');
Run Code Online (Sandbox Code Playgroud)
但是得到一个错误:
PHP 错误:在第 169 行的 /var/www/html/s/source/app/Http/Controllers/HomeController.php 中找不到“App\Http\Controllers\ReflectionFunction”类
我什至尝试使用全局命名空间:
ReflectionFunction 类不应该位于 laravel 试图找到它的地方,但是请建议我可能遗漏了什么?
在php中的MySql数据库中存储url时,我不得不使用以下内容,
mysql_real_escape_string('xyz/xyz.html')
不推荐使用mysql,现在我使用的是Yii 2.0(作者声称它是安全的).
我使用它的Gii CRUD,现在这个url很容易存储,不需要转义.
(如果它使用PDO,那么准备好的语句可能会解决上述问题)
我想知道Yii-2.0是否会处理与在数据库中存储事物然后将它们分散在视图上相关的重要安全问题.
我正在尝试更新我的依赖项以编译'com.google.firebase:firebase-core:11.0.2'但是
我得到的只是:
Failed to resolve: com.google.firebase:firebase-core:11.0.2'
Run Code Online (Sandbox Code Playgroud)
可能是什么原因?
最近的MySQL死机了,我只好到备份的内容var/lib/mysql
到/home/backup/
并重新安装数据库。
重新安装mysql服务器后,
重命名 /var/lib/mysql to mysql.orig
在/ var / lib中,我做了一个目录mysql
将内容从home/backup
文件夹移动到/ var / lib / mysql
现在通过运行mysql -u user -p
并在我调用show databases
它时出现以下错误:
MySql:错误1018(HY000):无法读取目录'。(错误:13)
如何解决呢?
我想要一个切换按钮,它的当前css背景颜色值为"红色".在第一次点击它应该变为'黄色',在第二次点击它变为'绿色',在第三次点击它应该变回'红色'.
HTML
<div id="box" class="boxa"> 1 </div>
使用Javascript:
$('div[id="box"]').mousedown(function(){
if($(this).css ('background-color', 'red')) {
$(this).css ('background-color', 'yellow');
}
});
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为$(this).css ('background-color', 'red')
总是返回true,然后尝试将值存储在变量中,然后像这样检查
var color = $(this).css ('background-color');
if (color=="red") {
// change it to some other color
}
Run Code Online (Sandbox Code Playgroud)
但这不能作为color
RGB中的返回值.谁能帮我写一个有效的解决方案.
我正在学习承诺.
app.get('/message',function(req, res){
var promise = new Promise(function(resolve, reject){
resolve("hi");
});
promise.then(function(message){
res.json(message);
})
});
Run Code Online (Sandbox Code Playgroud)
这很好用.虽然这太简单了.为了写"冗长"的东西,我把代码移出app.get()
并试图从外部函数返回消息......像这样:
app.get('/message',function(req, res){
var message = message(); // I also tried wrapping this in promise and calling `res.json` in `promise.then()` but no luck
res.json(message);
});
function message(){
var promise = new Promise(function(resolve, reject){
resolve("hi");
});
promise.then(function(message){
return message;
})
}
Run Code Online (Sandbox Code Playgroud)
那么为什么函数中的return语句不message()
返回消息呢?什么是将这些promising
代码移出路线功能的最佳做法?
我试图在Sequelize
模型中定义一个customFunction 。但是我得到一个错误:
TypeError:user.getJWT不是User.create.then的函数(/projects/test/a/app/controllers/UserController.js:22:29)
这是以下代码models/user.js
:
module.exports = function(sequelize, Sequelize) {
var User = sequelize.define('User', {
id: {
type: Sequelize.INTEGER(11),
allowNull: true,
primaryKey: true,
autoIncrement: true
},
user_id: {
type: Sequelize.STRING(255),
allowNull: true,
defaultValue: ''
}
});
User.prototype.getJWT = function() {
let expiration_time = parseInt(CONFIG.jwt_expiration);
return "Bearer " + jwt.sign({
user_id: this.user_id,
role: this.role
}, CONFIG.jwt_encryption, {
expiresIn: expiration_time
});
}
return User
}
Run Code Online (Sandbox Code Playgroud)
这就是我在控制器中调用此原型函数的方式...
User.create(body).then((user) => {
user.token = user.getJWT(); // and here I get the error …
Run Code Online (Sandbox Code Playgroud) php ×5
javascript ×3
yii2 ×3
laravel ×2
mysql ×2
node.js ×2
android ×1
asynchronous ×1
composer-php ×1
express ×1
firebase ×1
jquery ×1
phpdebugbar ×1
promise ×1
sequelize.js ×1
yii ×1