我安装了Laravel 5.7
在文件中添加了一个表单 \resources\views\welcome.blade.php
<form method="POST" action="/foo" >
@csrf
<input type="text" name="name"/><br/>
<input type="submit" value="Add"/>
</form>
Run Code Online (Sandbox Code Playgroud)
添加到文件 \routes\web.php
Route::post('/foo', function () {
echo 1;
return;
});
Run Code Online (Sandbox Code Playgroud)
发送POST请求后:
419抱歉,您的会话已过期.请刷新并重试.
在版本5.6
中没有这样的问题.
来自laravel docs
应用程序密钥安装Laravel后,您应该做的下一步是将应用程序密钥设置为随机字符串.如果通过作曲家或Laravel安装程序安装Laravel,这个密钥已经被设置为你的PHP工匠键:生成命令.
通常,此字符串应为32个字符长.密钥可以在.env环境文件中设置.如果您尚未将.env.example文件重命名为.env,则应立即执行此操作.如果未设置应用程序密钥,则您的用户会话和其他加密数据将不安全!
我对应用程序密钥的了解是:如果未设置应用程序密钥,通常我会得到一个例外.
我在 mac 上安装了 docker 桌面。所以为了启动docker,我打开应用,找到docker。然后我可以在顶栏看到一个泊坞窗图标。稍后我可以从命令行运行 docker 命令。
我的问题是如何从命令行启动 docker 本身?
谷歌搜索获取我如何从命令行启动容器的结果:|
我正在编写一个 Django 命令来为现有表做种,
我需要在播种前截断该表,但该表有外键约束。
因此,我在截断表时收到django.db.utils.IntegrityError,
如何在 Django 中暂时关闭外键检查?
我看到了,SET FOREIGN KEY CHECK = 0
但不知道把它们放在哪里:(
Django 命令类:
class Command(BaseCommand):
help = "Command to seed the aws regions"
regions = [
{
'name': 'Us East (N. Virginia)',
'region': 'us-east-1',
},
{
'name': 'US West (Oregon)',
'region': 'us-west-2',
},
{
'name': 'EU (Ireland)',
'region': 'eu-west-1',
},
]
def handle(self, *args, **options):
self.stdout.write('seeding regions...')
AwsRegions.objects.all().delete() # this is where i get errors
for name, region in self.regions:
self.stdout.write(region)
AwsRegions.objects.create(name, region) …
Run Code Online (Sandbox Code Playgroud) 我创建了一个新的 symfony4 项目。使用户实体使用php bin/console make:user
,然后尝试迁移使用php bin/console make:migration
。但随后弹出错误
在 AbstractPlatform.php 第 434 行中:
请求的数据库类型未知,Doctrine\DBAL\Platforms\MySQL57Platform 可能不支持。
奇怪的是 User 实体没有任何enum
类型,而是有一个 json 角色列,我想这就是原因。
/**
* @ORM\Column(type="json")
*/
private $roles = [];
Run Code Online (Sandbox Code Playgroud)
我已经看到了 laravel 类似问题的一些答案,但不知道如何在 symfony4 中修复它。
在开发银行应用程序时,在我的Laravel模型中,我有一个称为事务处理的表。
在该表中,有一列名为to_id和from_id,这是发送钱的用户的ID(from_id)和接收钱的用户的id(to_id),该ID链接到我的User表,
这是CreateTransactionsTable迁移代码
Schema::create('transactions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('from_id')->unsigned();
$table->foreign('from_id')->references('id')->on('users');
$table->bigInteger('to_id')->unsigned();
$table->foreign('to_id')->references('id')->on('users');
$table->integer('Amount');
$table->enum('TransactionType', ['Credit', 'Debit']);
$table->enum('Status', ['Completed', 'Incomplete']);
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
这是CreateUserTable迁移文件的代码
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->string('AccountNumber')->unique();
$table->rememberToken();
});
Run Code Online (Sandbox Code Playgroud)
这是事务模型的代码
class Transactions extends Model{
public function users(){
return $this->belongsTo('App\Users');
}
}
Run Code Online (Sandbox Code Playgroud)
这是用户模型的代码
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable{
use Notifiable;
protected $fillable = [
'name', 'email', 'password', 'Amount',
];
public function transactions(){
return $this->hasMany('App\Transactions');
} …
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的组件<AgentCard :agent="agent" />
,其中agent
有一个具有诸如等属性的对象FirstName, LastName, Recent Orders
......
现在我需要在 Google 地图信息框中显示此组件。该infoWindow.setContent()
方法(显示弹出信息窗口的 Google Maps API)仅接受 HTML 字符串,因此我尝试手动渲染<AgentCard>
,获取渲染组件的 HTML 内容,并将其传递给该setContent()
方法。
我尝试过Vue.compile('<AgentCard :agent="agent" />').render()
,但这不起作用。如何手动渲染 Vue 组件并获取其 HTML 内容?
我将所有控制器移至/src/Web/Controller
我的 Symfony 6 项目中,如下所示
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Web\n\xe2\x94\x82 | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Controller\n\xe2\x94\x82 | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ....\n| |\xe2\x94\x80\xe2\x94\x80 Kernel.php\n
Run Code Online (Sandbox Code Playgroud)\n我的routes.yaml
作相应修改
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ...\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Web\n\xe2\x94\x82 | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Controller\n\xe2\x94\x82 | \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ....\n| |\xe2\x94\x80\xe2\x94\x80 Kernel.php\n
Run Code Online (Sandbox Code Playgroud)\n现在的问题是我所有的路线都有一个前缀为的名称app_web
。我想这是由于这种结构。
$ php bin/console debug:router
命令输出如下:
...\n...\napp_web_post_index GET|HEAD ANY ANY /post/ \napp_web_post_create GET|HEAD|POST ANY ANY /post/create \n
Run Code Online (Sandbox Code Playgroud)\n在这里我只想要名字post_index
How do I摆脱这个前缀?
我已经阅读了依赖注入。然后来了
它们与依赖注入有何不同或它们都相同?注射在这里是什么意思?只是将所需的对象/参数提供给类?像构造注入意味着将所需参数作为构造函数参数传递?还是我错过了什么?
我正在尝试在打字稿中创建一个 chrome 扩展。
我有以下代码,我尝试从后台脚本向 contentscript 发送消息。
// background script
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "open_dialog_box"}, function(response) {
console.log(response);
});
});
Run Code Online (Sandbox Code Playgroud)
但是打字稿给出了以下错误
ERROR in /Users/shobi/Projects/Chrome Extensions/src/js/background.ts(8,37)
TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
Type 'undefined' is not assignable to type 'number'.
Run Code Online (Sandbox Code Playgroud)
我尝试使用 parseInt() 将 id 转换为整数,但仍然没有阻止错误。
php ×5
laravel ×3
symfony ×2
django ×1
docker ×1
doctrine-orm ×1
eloquent ×1
javascript ×1
laravel-5 ×1
macos ×1
postgresql ×1
symfony6 ×1
terminology ×1
typescript ×1
vue.js ×1