小编Ken*_*rna的帖子

命令行工具bash(git)无法正常工作 - macOS Sierra最终发布候选版

我刚刚从OS X 10.11"El Capitan"升级到10.12:"Sierra",当我尝试访问终端内的git命令时,我收到以下错误:

xcrun:错误:无效的活动开发人员路径

(/ Library/Developer/CommandLineTools),缺少xcrun:

/库/开发商/ CommandLineTools在/ usr/bin中/ xcrun

如果有人有解决方案,请帮助我.

macos terminal macos-sierra

81
推荐指数
2
解决办法
3万
查看次数

清除 React Hooks 中未安装组件的内存泄漏

我是使用 React 的新手,所以这可能很容易实现,但即使我做了一些研究,我也无法自己弄清楚。如果这太愚蠢,请原谅我。

语境

我将Inertia.js与 Laravel(后端)和 React(前端)适配器一起使用。如果你不知道惯性,它基本上是:

Inertia.js 可让您使用经典的服务器端路由和控制器快速构建现代单页 React、Vue 和 Svelte 应用程序。

问题

我正在做一个简单的登录页面,它有一个表单,提交时将执行 POST 请求以加载下一页。它似乎工作正常,但在其他页面中,控制台显示以下警告:

警告:无法对卸载的组件执行 React 状态更新。这是一个空操作,但它表明您的应用程序中存在内存泄漏。要修复,请取消 useEffect 清理函数中的所有订阅和异步任务。

在登录中(由 Inertia 创建)

相关代码(我已经对其进行了简化以避免不相关的行):

import React, { useEffect, useState } from 'react'
import Layout from "../../Layouts/Auth";

{/** other imports */}

    const login = (props) => {
      const { errors } = usePage();

      const [values, setValues] = useState({email: '', password: '',});
      const [loading, setLoading] = useState(false);

      function handleSubmit(e) {
        e.preventDefault();
        setLoading(true);
        Inertia.post(window.route('login.attempt'), values)
          .then(() => {
              setLoading(false); …
Run Code Online (Sandbox Code Playgroud)

javascript promise inertiajs reactjs react-hooks

39
推荐指数
2
解决办法
4万
查看次数

Laravel中允许的内存大小为536870912字节

在同一个系统中,我可以调用db,并且没有问题,但在某些情况下(使用最大的表),我得到了

"  SELECT partidascapturainfo.* FROM partidascapturainfo    WHERE partidascapturainfo.partidascapturainfoid IS NOT NULL       ORDER BY partidascapturainfoid asc   LIMIT  0 , 10 "
Run Code Online (Sandbox Code Playgroud)

我调试了代码,问题是一个基本的查询:

123044,42016,249,3762,2,,0
123045,42016,249,3761,2,,0
123046,42016,249,3764,1,,0
123047,42016,249,3765,,,0
123048,42016,249,3775,,,0
123049,42016,249,3771,3,,0
123050,42016,249,3772,3,,0
123051,42016,250,3844,HAY,,0
123052,42016,255,3852,,,0
123053,42017,249,3761,1,,0
Run Code Online (Sandbox Code Playgroud)

当我在Mysql客户端中运行查询时,查询运行在0.17s

我已经将memory_limit设置为2048,重新启动nginx并且我的查询只返回10行...

这是我的10行:

"  SELECT partidascapturainfo.* FROM partidascapturainfo    WHERE partidascapturainfo.partidascapturainfoid IS NOT NULL       ORDER BY partidascapturainfoid asc   LIMIT  0 , 10 "
Run Code Online (Sandbox Code Playgroud)

有什么想法发生了什么?

laravel

30
推荐指数
3
解决办法
9万
查看次数

更改命名空间时,在Laravel中找不到类'\ App\User'

我移动的时候有这个错误User.php给Models/User.php

local.ERROR:Symfony\Component\Debug\Exception\FatalThrowableError:致命错误:未找到类'\ App\User'

供应商/ laravel /框架/ SRC /照亮/认证/ EloquentUserProvider.php:126

laravel laravel-5.2

26
推荐指数
4
解决办法
5万
查看次数

错误:预期的Doctrine\ORM\Query\Lexer :: T_WITH,"开启"

我编写了以下代码来从数据库中获取数据

function getnotificationAction()
{
    $session = $this->getRequest()->getSession();
    $userId = $session->get('userid');

    $entitymanager = $this->getDoctrine()->getEntityManager();
    $notification = $entitymanager->getRepository('IGCNotificationBundle:Notifications');
    $userNotification = $entitymanager->getRepository('IGCNotificationBundle:Usernotifications');
    $query = $entitymanager
                 ->createQuery("SELECT n.notificationid, n.title,n.notificationmessage, u.creationdate, u.notificationid, u.messagestatus From IGCNotificationBundle:Notifications AS n JOIN IGCNotificationBundle:Usernotifications AS u ON u.notificationid = n.notificationid WHERE u.userId = :userId ORDER BY n.creationdate DESC")->setParameter('userId', userId);

    $notifications = $query->getResult();

    return $this->render('IGCNotificationBundle:Default:notification.html.twig', array('notifications' => $notifications));
} }
Run Code Online (Sandbox Code Playgroud)

但它是givin

function getnotificationAction()
{
    $session = $this->getRequest()->getSession();
    $userId = $session->get('userid');

    $entitymanager = $this->getDoctrine()->getEntityManager();
    $notification = $entitymanager->getRepository('IGCNotificationBundle:Notifications');
    $userNotification = $entitymanager->getRepository('IGCNotificationBundle:Usernotifications');
    $query = …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

19
推荐指数
1
解决办法
3万
查看次数

Laravel Passport为第一方应用授予Flow

我正在使用Laravel Passport来访问我的API的某些部分到第三方应用程序.

但是,我也通过自己的第一方原生Android应用程序使用自己的API.因此,在这种情况下,我查看整个互联网以获得最佳实践,但是仍然坚持得出结论.

以下是我发现的可能性:

可能性#01

我可以按照用户凭据密码授予流程.
在这种情况下,我需要传递一个client_secret和client_id授权服务器.为了保证他们的安全,我不能在我的移动应用程序的源代码中编写它们(APK可以解密...).

所以,我有两个选择.

可能性#01 - 选择A.

在调用oauth端点之前,通过我自己的服务器代理并注入秘密:

$proxy = Request::create('/oauth/token', 'post', [
    'grant_type' => 'password',
    'client_id' => 1,
    'client_secret' => 'myownclientsecretishere',
    'username' => $username,
    'password' => $password
]);
$proxy->headers->set('Accept', 'application/json');
$response = app()->handle($proxy);
Run Code Online (Sandbox Code Playgroud)

可能性#01 - 选择B.

使用中间件调用oauth端点时注入秘密:

class InjectPasswordGrantSecret
{
    public function handle($request, Closure $next)
    {
        $request->request->add([
            'client_id' => 1,
            'client_secret' => 'myownclientsecretishere'
        ]);
        return $next($request);
    }
}
Run Code Online (Sandbox Code Playgroud)

这些是工作示例,但它们在资源方面也很贪婪.我尝试在本地计算机上使用Apache基准测试,我得到了9个请求/秒.

可能性#02

我可以关注个人访问资助.
这个看起来不像OAuth2中 …

php security oauth-2.0 laravel laravel-passport

12
推荐指数
1
解决办法
1294
查看次数

工作尝试次数太多或运行时间太长

我有一份在当地完美无瑕的工作,但在生产中我遇到了无法解决的问题.我已经涵盖了整个handle()带try/catch和部署,尽管许多其他例外我没有看到任何东西记录到Bugsnag,在其他地方.

public function handle() {
    try {

        // do stuff

    } catch (\Exception $e) {
        Bugsnag::notifyException($e);

        throw $e;
    }
}
Run Code Online (Sandbox Code Playgroud)

根据Laravel Horizo​​n的说法,这个队列作业运行了0.0026001930236816406几秒钟,我从来没有看到它工作,也从未在failed_jobs表格中看到任何与此工作相关的其他错误.

配置/ queue.php

    'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => 'default',
        'retry_after' => (60 * 10), // 10 minutes
        'block_for' => null,
    ],
Run Code Online (Sandbox Code Playgroud)

配置/ horizo​​n.php

'environments' => [
    'production' => [
        'supervisor'        => [
            'connection'    => 'redis',
            'queue'         => [
                'default',
            ],
            'balance'       => 'auto', …
Run Code Online (Sandbox Code Playgroud)

queue laravel horizon

11
推荐指数
3
解决办法
5139
查看次数

测试方法使用存储失败.在Laravel中照亮\ Http\Testing\imagepng()

您好,我正在做TDD测试我的开发,我的测试正在通过,直到我决定重新安装php来修复sqlite驱动程序进行测试(主驱动程序是mysql).因此,当我运行我的测试套件时,每个使用以下方法的方法都会显示此错误storage:

错误:调用未定义功能照亮\ HTTP \测试\ imagepng(){} laravel {/framework/src/Illuminate/Http/Testing/FileFactory.php:46} laravel /framework/src/Illuminate/Support/helpers.php: 1038 {laravel} /framework/src/Illuminate/Http/Testing/FileFactory.php:49 {laravel} /framework/src/Illuminate/Http/Testing/FileFactory.php:31 {laravel} /tests/Feature/FacilityTest.php :38

这个是抛出上述错误的方法(线路38发出信号):

/**
 * @test
 * Test for: a Facility can be registered by an admin.
 */
public function a_facility_can_be_registered_by_an_admin()
{
    /** Given a correct information for a facility */
    \Storage::fake('public');

   // Next line is line 38, the problematic one:
    $data = ["name" => "AAA", 'image' => UploadedFile::fake()->image('aaa.jpg')];

    /** When the request is made by an …
Run Code Online (Sandbox Code Playgroud)

php testing tdd laravel laravel-5

10
推荐指数
1
解决办法
2268
查看次数

在AWS上执行"PutObject"时出错,上载失败

我已经建立了AWS帐户.我正在尝试将我的第一个程序化PUT转换为S3.我用控制台创建了一个桶并把东西放在那里.我还创建了一个子目录(myFolder)并将其公之于众.我创建了我的.aws/credentials文件并尝试使用示例代码,但是我收到以下错误:

在" https://s3.amazonaws.com/gps-photo.org/mykey.txt " 上执行"PutObject"时出错; AWS HTTP错误:客户端错误:PUT https://s3.amazonaws.com/gps-photo.org/mykey.txt导致403 Forbidden响应: PUT https://s3.amazonaws.com/gps-photo.org/mykey.txt访问DeniedFC49CD(截断...)AccessDenied(客户端):访问被拒绝 - 403 Forbidden访问被拒绝 FC49CD15567FB9CD1GTYxjzzzhcL + YyYsuYRx4UgV9wzTCQJX6N4jMWwA39PFaDkK2B9R + FZf8GVM6VvMXfLyI/4abo =

我的代码是

<?php

// Include the AWS SDK using the Composer autoloader.
require '/home/berman/vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$bucket = 'gps-photo.org';
$keyname = 'my-object-key';
// Instantiate the client.
$s3 = S3Client::factory(array(
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2006-03-01'
));
try {
    // Upload data.
    $result = $s3->putObject(array(
        'Bucket' => $bucket,
        'Key'    => "myFolder/$keyname", …
Run Code Online (Sandbox Code Playgroud)

php amazon-s3 amazon-web-services

8
推荐指数
5
解决办法
2万
查看次数

错误"此操作未经授权." 在Laravel 5.5

我做这样的门:

Gate::define('update-post', function  ($user, Post $post) {
    return $user->hasAccess(['update-post']) or $user->id == $post->user_id;
});
Run Code Online (Sandbox Code Playgroud)

我检查了我的数据库,它有更新帖子访问权限,用户ID与帖子相同.但我得到了:

此操作未经授权.

错误.所以我在这里犯了一些错误吗?谢谢.

php validation authorization laravel laravel-5

8
推荐指数
4
解决办法
2万
查看次数