小编Hak*_*kim的帖子

PHP curl连接超时错误

我在PHP中使用curl调用API,有时它工作正常,有时我得到 Failed to connect to api-domain.com port 80: Connection timed out

这有点奇怪,有时它正在工作,有时它不是.要解决我打印的问题,curl_getinfo()当它不工作时,请在下面查看.

它显示连接时间= 0和总时间= 130秒,我不确定它是什么意思.如果任何人对此有充分了解,请查看以下日志并帮助我了解具体问题.

[url] => http://api-domain.com/?act=get_story_banners
[content_type] => text/html; charset=UTF-8
[http_code] => 200
[header_size] => 630
[req   uest_size] => 283
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 130.335916
[namelookup_time] => 0.000016
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 744
[speed_download] => 13814
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] …
Run Code Online (Sandbox Code Playgroud)

php curl php-curl

11
推荐指数
2
解决办法
5630
查看次数

使用可通过api平台软删除的Doctrine扩展

我正在使用Symfony 3.4和api平台构建API。我想在实体上使用软删除。我已经安装DoctrineExtensionsStofDoctrineExtensionsBundle

config.yml

doctrine:
    dbal:
        connections:
            default:
               […]

    orm:
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore
                connection: default
                mappings:
                    […]
                filters:
                    softdeleteable:
                        class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
                        enabled: true
Run Code Online (Sandbox Code Playgroud)

而我的实体:

<?php

namespace AppBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * MyEntity
 *
 * @ORM\Table(name="MyEntity", schema="MyEntity")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\MyEntityRepository")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 * @ApiResource
 */
class MyEntity
{
    /**
     * @var \DateTime
     * @ORM\Column(name="deleted_at", type="datetime")
     */
    private $deletedAt;

    […]
Run Code Online (Sandbox Code Playgroud)

这是行不通的。我知道我需要配置一些东西(即EventManager),但我不知道如何做。这是我尝试创建实体时遇到的错误

Listener "SoftDeleteableListener" was not added to the EventManager!

我认为我已经完成了该页面说明的所有内容: …

soft-delete symfony doctrine-extensions api-platform.com

7
推荐指数
1
解决办法
933
查看次数

Symfony2已登录但未在Profiler中进行身份验证

我正在Symfony 2.6上创建一个身份验证系统.注册过程有效.当我尝试登录时,我已登录并且我有"ROLE_USER",但是探查器说我没有通过身份验证.我不明白发生了什么.这是用户实体:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* User
*
* @ORM\Table(name="baseuser")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
* @UniqueEntity("email", message="error.user.email.taken")
*/
class User implements UserInterface, \Serializable
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="email", type="string", length=255, unique=true)
 */
private $email;

/**
 * @var string
 *
 * @ORM\Column(name="username", type="string", length=70, nullable=true)
 */
private $username;

/**
 * @var string …
Run Code Online (Sandbox Code Playgroud)

php authentication symfony

2
推荐指数
1
解决办法
4518
查看次数

Symfony2 JMSSerializerBundle在YML中公开属性

我想使用JMSSerializerBundle和FOSRestBundle仅公开我的User类的一些属性.似乎序列化程序包没有读取我的配置文件.

我的用户类在src/AppBundle/Entity/User,它扩展了FOSUserBundle用户类.

这是我的User类:

  <?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * User
 *
 * @ORM\Table(name="backoffice_user")
 * @ORM\Entity(repositoryClass="AppBundle\Entity\Repository\UserRepository")
 */
class User extends BaseUser
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="lastname", type="string", length=70)
     */
    private $lastname;

    /**
     * @var string
     *
     * @ORM\Column(name="firstname", type="string", length=70)
     */
    private $firstname;
}
Run Code Online (Sandbox Code Playgroud)

这是我的app/config.yml文件

jms_serializer:
    metadata:
        debug: true
        auto_detection: …
Run Code Online (Sandbox Code Playgroud)

configuration-files symfony jmsserializerbundle

2
推荐指数
1
解决办法
4087
查看次数

Symfony2中的特征错误

我需要在symfony2中使用Traits.扩展不同父母的不同存储库仍然使用一些常用方法.我创建了一个包含这些常用方法的特征.不幸的是,当我调用该动作时,Symfony2抛出一个错误说:

Parse Error: syntax error, unexpected 'Trait' (T_TRAIT), expecting identifier (T_STRING)
in src/AppBundle/Entity/Repository/CategoryRepository.php line 14
Run Code Online (Sandbox Code Playgroud)

这是一个存储库

namespace AppBundle\Entity\Repository;

use Gedmo\Tree\Entity\Repository\NestedTreeRepository;
use AppBundle\Trait\HasDomainRepositoryTrait;
/**
 * CategoryRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class CategoryRepository extends NestedTreeRepository
{
    use HasDomainRepositoryTrait;

    public function search($domain, $onlyActive, $searchString = null)
    {
        $builder = $this->createBaseQuery($domain, $onlyActive);

        if ($searchString) {
            $builder
                    ->andWhere('e.name LIKE :searchString')
                    ->setParameter('searchString', '%'.strtolower($searchString).'%')
                    ;
        }

        return $builder;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是特质:

namespace …
Run Code Online (Sandbox Code Playgroud)

php traits symfony

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