我想在OSX 10.11上安装宅基地.我想要建立laravel应用程序.我无法从命令行运行homestead.当我尝试全局安装它时,我收到一个错误:
$ composer global require "laravel/homestead=~2.0"
Changed current directory to /Users/connorleech/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install laravel/homestead v2.1.8
- Conclusion: don't install laravel/homestead v2.1.7
- Conclusion: don't install laravel/homestead v2.1.6
- Conclusion: don't install laravel/homestead v2.1.5
- Conclusion: don't install laravel/homestead v2.1.4
- Conclusion: don't install laravel/homestead v2.1.3
- Conclusion: …Run Code Online (Sandbox Code Playgroud) 嘿,我正在尝试在新的ubuntu机器上安装rails.我安装了ruby和rvm但是我收到了"未能构建gem native扩展"的错误.这是什么意思?
$ sudo gem install rails -v 3.2.9
Run Code Online (Sandbox Code Playgroud)
(没有sudo说我没有权限)
然后它输出了很多'抓取'命令,最终输出了这个错误:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
Run Code Online (Sandbox Code Playgroud)
当我输入
$rails server
Run Code Online (Sandbox Code Playgroud)
它说当前没有安装rails
我正在尝试启动一个节点应用程序,我认为rabbitmq正在阻碍.
与此主题类似:"名称为"兔子"已经在运行",但"无法连接到节点'兔子'"
$ ps aux | grep erl
rabbitmq 1327 0.0 0.0 2376 300 ? S Dec13 0:00 /usr/lib/erlang/erts-5.8.5/bin/epmd -daemon
rabbitmq 1344 0.0 0.3 59560 14888 ? Sl Dec13 0:10 /usr/lib/erlang/erts-5.8.5/bin/beam.smp -W w -K true -A30 -P 1048576 -- -root /usr/lib/erlang -progname erl -- -home /var/lib/rabbitmq -- -noshell -noinput -sname rabbit@jasonshark -boot /var/lib/rabbitmq/mnesia/rabbit@jasonshark-plugins-expand/rabbit -kernel inet_default_connect_options [{nodelay,true}] -sasl errlog_type error -sasl sasl_error_logger false -rabbit error_logger {file,"/var/log/rabbitmq/rabbit@jasonshark.log"} -rabbit sasl_error_logger {file,"/var/log/rabbitmq/rabbit@jasonshark-sasl.log"} -os_mon start_cpu_sup true -os_mon start_disksup false -os_mon start_memsup false -mnesia dir …Run Code Online (Sandbox Code Playgroud) 我试图修改我的gruntfile但是我的缩进有很多错误.空格是否总是对gruntfiles很重要?什么是解决这些错误的最佳方法,计算空格?
$ grunt
Running "newer:jshint" (newer) task
Running "newer:jshint:all" (newer) task
Running "jshint:all" (jshint) task
Gruntfile.js
line 33 col 11 Expected 'options' to have an indentation at 9 instead at 11.
line 36 col 7 Expected '}' to have an indentation at 9 instead at 7.
line 37 col 7 Expected 'js' to have an indentation at 9 instead at 7.
line 38 col 9 Expected 'files' to have an indentation at 11 instead at 9.
line 39 col 9 …Run Code Online (Sandbox Code Playgroud) 我有一个用yeoman的generator-angular生成的网站,我想用github页面发布这个网站.我创建了gh-pages分支但我的repo没有出现在myusername.github.io/myreponame我认为原因是因为index.html在app/目录而不是根目录.
app/
|-- index.html
|-- scripts/
dist/
Gruntfile.js
etc..
我可以告诉github页面从app文件夹加载index.html吗?如何启动带有角度生成器的网站到gh页面?
当我尝试像这样注入"ngAnimate"时,我无法实例化我的应用程序:
var app = angular.module('musicsa', [
'ngCookies',
'ngResource',
'ngSanitize',
'ui.router',
'firebase',
'ngAnimate'
])
Run Code Online (Sandbox Code Playgroud)
我Uncaught object从angular.js第78行得到一个错误
我使用bower安装了ngAnimate.这是我的bower.json:
{
"name": "ang-changeorg",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.6",
"json3": "~3.2.6",
"es5-shim": "~2.1.0",
"jquery": "~1.10.2",
"bootstrap": "~3.0.3",
"angular-resource": "1.2.6",
"angular-cookies": "1.2.6",
"angular-sanitize": "1.2.6",
"firebase": "~1.0.11",
"angularfire": "~0.7.1",
"spin.js": "~2.0.0",
"angular-ui-router": "~0.2.10",
"angular-animate": "~1.2.16"
},
"devDependencies": {
"angular-mocks": "1.2.6",
"angular-scenario": "1.2.6"
},
"resolutions": {
"angular": "1.2.6"
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的所有脚本中包含index.html:
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script> …Run Code Online (Sandbox Code Playgroud) 我有一个带有五个计算属性函数的 Vue 实例,它们对不同的值执行相同的操作。我重复了很多次,并且想知道一种更干净的方法来做到这一点,而不需要重复太多。
在 HTML 模板中,我有 5 个输入字段,每个输入字段限制为 25 个字符,我想显示我显示一个字符计数器:
<div class='field is-grouped'>
<p class='control is-expanded'>
<input
class="input"
placeholder="Trophy engraving line 1 (25 character limit)"
v-model='engraving.line1'
v-validate="'required'"
:class="{'input': true, 'is-danger': errors.has('engraving.line1') }"
name='engraving.line1'>
</p>
<p class='control'>
<span>{{ line1count }}</span>
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我有五个看起来完全一样的字段,除了它们说engraving.line2, engraving.line3,engraving.line4和engraving.line5。
然后我的组件 javascript 定义了雕刻对象,并对每个字段具有相同的计算方法。
export default {
data(){
return {
engraving: {
line1: '',
line2: '',
line3: '',
line4: '',
line5: '',
}
};
},
computed: {
line1count() {
var chars …Run Code Online (Sandbox Code Playgroud) 我有一个 Laravel Eloquent 查询,我试图从 MySQL 表中选择多个列。
$query = DB::connection('global')
->select(
'mytable.id',
'mytable.column1',
'mytable.another_column',
'mytable.created_at',
'myothertable.id
)
->from('mytable')
->get();
Run Code Online (Sandbox Code Playgroud)
看起来 select() 函数需要三个参数:query、bindings 和 useReadPdo。上面的查询给了我一个错误:
{"error":true,"message":"Type error: Argument 1 passed to Illuminate\\Database\\Connection::prepareBindings() must be of the type array, string given" }
Run Code Online (Sandbox Code Playgroud)
如何使用 Laravel 查询生成器为上述列编写选择?
我以这种方式构造查询,因为我希望在另一个表之间进行联接,如下所示:
$query = DB::connection('global')
->select(
'mytable.id',
'mytable.column1',
'mytable.another_column',
'mytable.created_at',
'myothertable.id
)
->from('mytable')
->leftJoin('myothertable', function($join){
$join->on('mytable.id', '=', 'myothertable.id');
})
->get();
Run Code Online (Sandbox Code Playgroud)
如何使用 Eloquent 查询生成器使用 select 函数跨表抓取多个列?
我按照这个答案在我的应用程序中发布了默认的电子邮件模板:
php artisan vendor:publish --tag=laravel-notifications
php artisan vendor:publish --tag=laravel-mail
Run Code Online (Sandbox Code Playgroud)
这很好用,但显然有一些配置选项,例如:
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level === 'error')
# @lang('Whoops!')
@else
# @lang('Hello!')
@endif
@endif
{{-- Salutation --}}
@if (! empty($salutation))
{{ $salutation }}
@else
@lang('Regards'),<br>{{ config('app.name') }}
@endif
Run Code Online (Sandbox Code Playgroud)
现在我的电子邮件正在发送“你好!” 和来自 else 部分的“问候”,但显然有一种方法可以使用变量为电子邮件模板设置这些默认值。发送电子邮件时如何设置$greeting和$salutation变量?
我有一个Laravel 5.5应用程序,具有管理员权限的用户可以上传文件.他们上传文件后我希望他们能够在管理员仪表板中查看该文件.
我有一个DocumentController.php来处理文件上传到本地磁盘:
public function store(Request $request)
{
// check to make sure user is an admin
$request->user()->authorizeRoles('admin');
// validate that the document is a pdf and
// that required fields are filled out
$this->validate($request, [
'title' => 'required',
'description' => 'required',
'user_id' => 'required|exists:users,id',
'document_path' => 'required|mimes:pdf'
]);
$file = $request->file('document_path');
$path = $file->store('documents/' . $request->user_id);
$document = Document::create([
'user_id' => $request->user_id,
'title' => $request->title,
'description' => $request->description,
'file_path' => $path
]);
return redirect($document->path());
}
Run Code Online (Sandbox Code Playgroud)
此方法从表单中获取文件,确保它是pdf,然后将文件保存到storage/app/documents/{user_id} …
laravel ×4
laravel-5 ×4
php ×4
angularjs ×2
javascript ×2
angular-ui ×1
bower ×1
eloquent ×1
file-upload ×1
github ×1
github-pages ×1
gruntjs ×1
homestead ×1
jshint ×1
laravel-mail ×1
ng-animate ×1
node.js ×1
pid ×1
rabbitmq ×1
ruby ×1
ubuntu-12.04 ×1
vagrant ×1
vue.js ×1
vuejs2 ×1
yeoman ×1