我正在尝试建立Laravels Valet(Valet是Mac的Laravel开发环境).一切正常,直到命令"valet install".该命令必须在终端中执行.但我得到错误"命令未找到".有什么想法,为什么?我是否必须更新我的PATH或其他内容?
我几天前切换到OS X. 在此之前,我是一名Windows用户.所以我是一个新手.
我试图从我的Vue-Instance渲染对象列表.每个对象都应该使用一个组件,因此我将组件放入v-for-loop中.但我得到的只是list.title而list.text不是正确的值.
是否有一种在v-for-loops中使用组件的特殊方法?
我在Vue-Forum中找到了这个帖子,但不知道如何使用它或者它是否正确.
应用程序:
<div id="app">
<div v-for="list in lists">
<listcard title="list.title" text="list.text"></listcard>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
模板:
<template id="listcard-template">
<div class="card">
<h2>{{ title }}</h2>
<p>{{ text }}</p>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我的组件:
Vue.component('listcard', {
template: '#listcard-template',
props: ['title', 'text']
})
Run Code Online (Sandbox Code Playgroud)
Vue公司-实例:
new Vue({
el: "#app",
data: {
lists: [
{title: "title1", text: "text1"},
{title: "title2", text: "text2"},
...
]
}
})
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在尝试构建一个混合应用程序Cordova。我使用 VueJS 进行路由和 AJAX 请求。
不幸的是我无法捕捉到一些事件Cordova。甚至该deviceReady活动也不起作用。
这是我的文件:
require('./bootstrap');
var Vue = require('vue');
var VueRouter = require('vue-router');
Vue.use(VueRouter);
// Some components
Vue.component('test', require('./Vue/components/test.vue'));
Vue.component('mainnav', require('./Vue/partials/mainnav.vue'));
// Route-components
const Home = Vue.component('home', require('./Vue/pages/home.vue'));
const Login = Vue.component('login', require('./Vue/pages/auth/login.vue'));
const Register = Vue.component('register', require('./Vue/pages/auth/register.vue'));
const notFound = Vue.component('notFound', require('./Vue/pages/404.vue'));
// the routes
const routes = [
{ path: '', component: Home },
{ path: '/', component: Home },
{ path: '/login', component: Login },
{ path: '/register', …Run Code Online (Sandbox Code Playgroud) 我想用 php 7.2.10-fpm、nginx 和 mysql 5.7 设置一个小型 docker 环境,以便在其中运行 Laravel 5.7。不幸的是,当我尝试从我的应用程序服务连接到 mysql(尝试运行docker-composer exec app php artisan migrate)时,出现以下错误:
In Connector.php
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Run Code Online (Sandbox Code Playgroud)
尝试运行docker-compose exec app mysql -u root -p返回:错误2002(HY000):无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2“没有这样的文件或目录”)
通过启动和构建我的容器docker-compose up --build不会引发任何错误。它说 mysql 正在运行并等待连接。我还通过删除并重新创建了所有图像docker system prune --force --volumes。
也许我错过了 docker-compose.yml 中的某些内容?
version: '3.3'
services:
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./../backend:/var/www
environment: …Run Code Online (Sandbox Code Playgroud) 我已将 Laravel Nova 添加到我的 Laravel 应用程序 (v7.x) 中。我的中间件/服务提供商/等中没有任何特殊配置。
每当我从 Nova 提交表单时,都会出现错误419 Page expired。
抛出VerifyCsrfTokenMiddleware一个错误,指出存在“CSRF 令牌不匹配”。
所有视图和资源都是默认的,因为它们来自 Laravel Nova 安装脚本。
任何想法,是什么导致了这个问题?
当我尝试将模型中的属性转换为枚举之一时,它会抛出错误:
调用未定义的方法 App\Enums\UserType::from()
我找不到任何有关所需find()方法的信息。
我按照这里的说明进行操作。
我的枚举UserType:
namespace App\Enums;
enum UserType
{
case CUSTOMER;
case PARTNER;
case ADMIN;
}
Run Code Online (Sandbox Code Playgroud)
和我的用户模型:
namespace App\Models;
use App\Enums\UserType;
use FaarenTech\LaravelCustomUuids\Interfaces\HasCustomUuidInterface;
use FaarenTech\LaravelCustomUuids\Models\UuidModel;
use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableInterface;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableInterface;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Auth\Authenticatable;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Auth\Passwords\CanResetPassword;
class User extends UuidModel implements
AuthorizableInterface,
AuthenticatableInterface,
CanResetPasswordInterface,
HasCustomUuidInterface
{
use
HasApiTokens,
HasFactory,
Notifiable,
Authenticatable,
Authorizable,
CanResetPassword,
MustVerifyEmail,
SoftDeletes;
/** …Run Code Online (Sandbox Code Playgroud) 我想编写自己的中间件来检查当前用户是否是某个组的成员。如果是,用户可以移动到路由,如果不是,用户将被重定向到不同的页面。
我的中间件正在工作,但我不知道如何获取当前用户 ID。我试过 Auth::user() 方法,但没有成功。
这是我的中间件:
namespace App\Http\Middleware;
use Closure;
use App\User;
use App\Usergroups;
use Illuminate\Http\Request;
class UserGroupMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next, $group = NULL)
{
$user_id = $request->user()->user_id;
$user = User::find($user_id);
$usergroup = Usergroups::find($user->benutzergruppe);
if($usergroup->slug == 'admin'){
return $next($request);
}
return redirect('/');
}
}
Run Code Online (Sandbox Code Playgroud) 我发现,我的 Laravel (5.7) 应用程序在某些情况下有一个奇怪的行为,它执行两个表单提交请求。上周一切正常。
例如:有一个注册表。当用户想要注册并提交表单时,他无法通过验证,因为输入的电子邮件地址已经存在(在他提交表单之前并不正确)。在我的数据库中一瞥向我展示了用户已创建并登录。因此,表单似乎以某种方式执行了两个请求。
这种行为发生在整个应用程序的几种形式上,但不是全部。这会导致一些非常糟糕的操作(上面的操作,电子邮件发送两次,图像上传两次等)。
一个可能的问题原因可能是一个新的中间件,我在其中访问当前请求并对其执行一些操作:
class CookiebannerMiddleware
{
public function handle(Request $request, Closure $next)
{
$cookie_name = config('cookiebanner.cookie_key');
$cookie_value = config('cookiebanner.cookie_value');
$cookie_lifetime = config('cookiebanner.cookie_lifetime');
$response = $next($request);
if(!$request->hasCookie($cookie_name)){
$response->cookie($cookie_name, $cookie_value, $cookie_lifetime);
return $response;
}
return $next($request);
}
}
Run Code Online (Sandbox Code Playgroud)
或者还有其他可能导致此类问题的可能性吗?
更新
问题是我的 CookiebannerMiddleware。该问题已通过以下解决方案解决:
class CookiebannerMiddleware
{
public function handle(Request $request, Closure $next)
{
$cookie_name = config('cookiebanner.cookie_key');
$cookie_value = config('cookiebanner.cookie_value');
$cookie_lifetime = config('cookiebanner.cookie_lifetime');
if(!$request->hasCookie($cookie_name)){
return $next($request)->withCookie($cookie_name, $cookie_value, $cookie_lifetime);
}
return $next($request);
}
}
Run Code Online (Sandbox Code Playgroud) 我有问题通过sftp连接到我的ubuntu 14.04服务器.每次我尝试连接时,都会收到以下信息/错误消息:
Sep 18 15:04:47 localhost sshd[2917]: Accepted password for junperbo from 87.129.13.92 port 59333 ssh2
Sep 18 15:04:47 localhost sshd[2917]: pam_unix(sshd:session): session opened for user junperbo by (uid=0)
Sep 18 15:04:47 localhost systemd-logind[2427]: Removed session 2.
Sep 18 15:04:47 localhost systemd-logind[2427]: New session 3 of user junperbo.
Sep 18 15:04:48 localhost sshd[2954]: fatal: bad ownership or modes for chroot directory component "/var/www/"
Sep 18 15:04:48 localhost sshd[2917]: pam_unix(sshd:session): session closed for user junperbo
Run Code Online (Sandbox Code Playgroud)
我是管理我的Ubuntu服务器的新手,所以请详细说明你的答案.我知道问题可以通过"chmod"或/和"chown"来解决,但是怎么样?
请记住,我已经使用此子系统编辑了我的sshd_config:
Subsystem sftp internatl-sftp
Match …Run Code Online (Sandbox Code Playgroud) 我的问题是我无法通过 config() 函数设置我的配置值。
我有自己的配置文件(在 config/ 中的 cms.php)。我要更改的值是“索引”。
在我的 ConfigController 中,我尝试使用以下方法设置值:
config(['cms.index' => $page_id]);
Run Code Online (Sandbox Code Playgroud)
任何解决方案?我必须导入一个特殊的类吗?
是否可以在 Laravel 的控制器中运行 composer 或 git 命令?类似的东西:
class TestController extends Controller
{
//
public function shell(Request $request){
if($request->isMethod('post')){
$data['output'] = shell_exec('composer update');
// or some git commands
return view('tests.shell', $data);
} else {
return view('tests.shell');
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我按照上面显示的方式进行操作,则不会收到任何消息。我认为,问题是,这些命令必须在项目根目录中运行,而不是在子文件夹中。
是否有一个 php 函数可以运行完整的 shell 脚本而不仅仅是单个命令?
我已经测试过这个:
echo shell_exec('php ' . __DIR__ . '/../shell.php');
// shell.php is in projects root directory
Run Code Online (Sandbox Code Playgroud)
脚本被执行,但不在根目录中。
谢谢!
laravel ×5
php ×5
composer-php ×2
javascript ×2
laravel-5 ×2
vue.js ×2
cmd ×1
config ×1
cordova ×1
docker ×1
enums ×1
laravel-nova ×1
middleware ×1
mysql ×1
ownership ×1
php-8.1 ×1
request ×1
sftp ×1
shell ×1
ubuntu ×1