我创建了一个新的Lumen 5.4项目并尝试播种一些数据.在播种机中,我使用bcrypt来哈希密码.但是当我跑步时php artisan db:seed,我收到了这个错误:
Call to undefined function bcrypt()
Run Code Online (Sandbox Code Playgroud)
为什么我不能在流明中使用bcrypt?我之前在Laravel中使用过它.
我正在尝试创建一个MEAN crud操作.我在节点中有一个带有删除http方法的api localhost:3000/api/user?id=<some document id>.下面是我使用的角度代码:
deleteUser(user) {
console.log("user to delete:" + user._id);
let myParams = new URLSearchParams();
myParams.append('id', user._id);
return this.http.delete('/api/user', { search: myParams })
.map(res => res.json());
}
Run Code Online (Sandbox Code Playgroud)
正确的ID正在打印到控制台,但我甚至无法看到在Chrome网络栏中进行的呼叫,也没有删除数据.出了什么问题?
我试图让服务器安装无头镀铬,selenium webdriver和量角器,以实现自动化测试.
我按照这些说明设置了我的环境:
# JDK 8
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update && sudo apt-get install openjdk-8-jdk
# Node JS
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get install -y nodejs
# NPM modules
sudo npm install protractor -g
sudo npm install chromedriver -g
# Google Chrome
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4 …Run Code Online (Sandbox Code Playgroud) 我正在尝试集成node-postgres驱动程序并学习做一个简单的 CRUD 操作。在我的app.js,我做这样的事情:
...
var postgres = require('./adapters/postgres')
var postClient = new postgres(conf);
...
postClient.connect(function (dbconn) {
app.dbconn = dbconn;
app.conf = conf;
console.log("************************************************************");
console.log(new Date() + ' | CRUD Server Listening on ' + conf['web']['port']);
console.log("************************************************************");
server.listen(conf['web']['port']);
var Routes = require('./routes/http-routes');
new Routes(app);
});
Run Code Online (Sandbox Code Playgroud)
在我的adapters/postgres.js文件中,我有以下内容:
const Client = require('pg');
const postClient = new Client(conf)({
host: conf['postgres'].host,
port: conf['postgres'].port,
dbname: conf['postgres'].dbname,
username: conf['postgres'].username,
password: conf['postgres'].password,
dbconn: null,
});
module.exports = postClient;
postClient.prototype.connect = function …Run Code Online (Sandbox Code Playgroud) 我有一个使用express和运行的Node应用程序jsonwebtoken.在每次请求api调用jsonwebtoken之前,我都进行了检查.我已手动排除下面的路线.有没有更好的方法从这里排除一些路线?我怎样才能做到这一点?
import * as express from 'express';
import * as jwt from 'jsonwebtoken';
import UserCtrl from './controllers/user';
export default function setRoutes(app) {
const router = express.Router();
// route middleware to verify a token
router.use(function (req, res, next) {
if ((req.method == 'POST' || req.method == 'OPTIONS') && (req.url == '/user' || req.url == '/login' || req.url == '/user/activate')) {
next();
} else {
// check header or url parameters or post parameters for token
var token …Run Code Online (Sandbox Code Playgroud) 我想将整数转换为二进制字符串.我选择使用java允许的本机函数Integer.toBinaryString(n).但不幸的是,这会从我的输出中减少前导零.让我们举例说,我给输入18,它给我输出10010但实际输出应该是010010.将int转换为字符串是否比编写用户定义的函数更好/更短?或者我在这里做错了什么?
int n = scan.nextInt();
System.out.println(Integer.toBinaryString(n));
Run Code Online (Sandbox Code Playgroud) 我为特定用户的所有地址列表创建了一个集合,并将其命名为:
$addresses = collect($user->GetAddress);
$addresses = $addresses->where('deleted', 0);
$addresses = $addresses->except(['deleted', 'created_at', 'updated_at']);
Run Code Online (Sandbox Code Playgroud)
我得到的输出如下:
[
{
"id": 1,
"user_id": 1,
"name": "mr.test",
"line1": "test1",
"line2": "test2",
"pincode": 100,
"city": "test3",
"state": "test4",
"mobile": "test5",
"default": 0,
"deleted": 0,
"created_at": "2017-02-23 09:20:09",
"updated_at": "2017-02-23 09:20:09"
}
]
Run Code Online (Sandbox Code Playgroud)
它仍然返回我做的字段,除了.我究竟做错了什么?
我甚至试过这些:
$addresses = $addresses->each(function ($item, $key) {
return $item->except(['deleted', 'created_at', 'updated_at']);
});
Run Code Online (Sandbox Code Playgroud)
和
$addresses = $addresses->each->except(['deleted', 'created_at', 'updated_at']);
Run Code Online (Sandbox Code Playgroud) 所以我试图通过创建一个应用程序来学习一些基本的Angular,该应用程序使用OpenWeather API获取并显示某个位置的当前天气.
这就是我目前代码中的内容:
app.component.ts:
import { Component } from '@angular/core';
import { WeatherService } from './weather.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [WeatherService]
})
export class AppComponent {
title = 'Ng-Weather';
cityName: string;
weather: Weather;
constructor(private weather: WeatherService) { }
search() {
this.weather.getWeatherbyName(this.cityName)
.subscribe(res => this.weather = res);
console.log(this.weather);
}
}
Run Code Online (Sandbox Code Playgroud)
weather.service.ts:
import { Injectable } from '@angular/core';
import { Http, Response, URLSearchParams } from '@angular/http';
import { Observable } from 'rxjs';
import { Weather } from './weather'; …Run Code Online (Sandbox Code Playgroud) node.js ×3
angular ×2
binary ×1
collections ×1
express ×1
java ×1
json ×1
laravel ×1
lumen ×1
php ×1
postgresql ×1
typescript ×1