小编shu*_*van的帖子

Xdebug 无法连接到调试客户端。尝试过:本地主机:9000

我在 Xdebug v2 之前使用过,但在上次更新后我遇到了 Xdebug v3.0.0,我替换了更新用户指南所需的所有内容

我正在使用 Docker。

我的调试配置

#xdebug.remote_enable=true
xdebug.mode=debug

#xdebug.remote_port=9000
xdebug.client_port=9000

xdebug.remote_host=172.17.0.1

xdebug.remote_handler=dbgp

#xdebug.remote_autostart=1
xdebug.start_with_request=yes

#xdebug.remote_connect_back=0
xdebug.discover_client_host=0

xdebug.idekey=PHPSTORM
xdebug.show_error_trace = 1
xdebug.max_nesting_level=250
xdebug.var_display_max_depth=10
#xdebug.remote_mode=req

xdebug.remote_log=/var/log/r_xdebug.log
xdebug.log=/var/log/xdebug.log
Run Code Online (Sandbox Code Playgroud)

以及我在尝试执行任何 PHP 脚本时得到的日志:

tail -f /var/log/xdebug.log
[888] Log opened at 2020-11-29 10:39:51.670762
[888] [Step Debug] INFO: Connecting to configured address/port: localhost:9000.
[888] [Step Debug] WARN: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
[888] [Step Debug] WARN: Creating socket for 'localhost:9000', connect: Cannot assign requested …
Run Code Online (Sandbox Code Playgroud)

php xdebug docker

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

查询生成器选择实体关系 ID

我有一些查询,我需要在选择块中选择 id 关系实体,如果没有一些连接,我该如何做到这一点,就像在 SQL 中一样?在示例中,我添加了 leftJoin 但我想了解没有连接也是可能的,lsc.serviceCompany.id或者如何?

        $qb
        ->select('
            ser_com.id as serviceCompanyId 
        ')
        ->from('AppBundle:LocationServiceCompany', 'lsc')
        ->leftJoin('lsc.serviceCompany', 'ser_com')
        ->where('lsc.serviceCompany = :sc')
        ->setParameter('sc', $serviceCompany);
Run Code Online (Sandbox Code Playgroud)

mysql query-builder symfony doctrine-orm

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

作曲家无法加载包无效的版本字符串

我遇到了范围情况,当我尝试在本地安装一些包时,我遇到了错误,但是当我尝试在测试服务器中安装相同的包时,所有安装都没有错误。我使用 docker-compose 并在图像中安装包。docker-copose 和其他所有依赖项绝对相同的 docker 文件,都在 git 中。

composer require league/flysystem-bundle

在当地我遇到了那个

使用版本 dev-master for League/flysystem-bundle ./composer.json 已更新 使用包信息加载 composer 存储库 更新依赖项(包括 require-dev) 将“symfony/symfony”中列出的包限制为“5.0.*”

安装失败,将 ./composer.json 恢复为其原始内容。

  [RuntimeException]                                                           
  Could not load package ezsystems/ezplatform in http://repo.packagist.org: [  
  UnexpectedValueException] Could not parse version constraint dev-load-varni  
  sh-only-when-used as ^2.0@dev: Invalid version string "^2.0@dev"             
                                                                               

                                                                               
  [UnexpectedValueException]                                                   
  Could not parse version constraint dev-load-varnish-only-when-used as ^2.0@  
  dev: Invalid version string "^2.0@dev" 
Run Code Online (Sandbox Code Playgroud)

本地作曲家版本作曲家版本 1.10.11 2020-09-08 16:53:44

和测试服务器

/var/www/symfony # composer require league/flysystem-bundle
Using version dev-master for league/flysystem-bundle
./composer.json …
Run Code Online (Sandbox Code Playgroud)

symfony composer-php docker

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

Google api refresh_token null以及如何刷新访问令牌

我使用HWIO Bundle for google api,当我收到来自google refreshToken = null的回复为什么?如何刷新令牌

oAuthToken = {HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken} [11]
accessToken = "ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg"
rawToken = {array} [4]
 access_token = "ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg"
 token_type = "Bearer"
 expires_in = 3578
id_token = "xxxxx"
refreshToken = null
expiresIn = 3578
createdAt = 1468957368
tokenSecret = null
resourceOwnerName = null
Run Code Online (Sandbox Code Playgroud)

因为在google/apiclient中,"version":"1.1.7"在函数中需要refresh_token

 public function getRefreshToken()
 {
  if (array_key_exists('refresh_token', $this->token)) {
    return $this->token['refresh_token'];
  } else {
    return null;
  }
 }
Run Code Online (Sandbox Code Playgroud)

这是我的访问令牌

{"access_token":"ya29.Ci8lA1JTu9CB81dOFy-nzszViRgCI2CvvKVrCd0Lq-8I0QR_dIrl-_7RccdGt1Islg","token_type":"Bearer","expires_in":3578,"id_token":"xxxx","created":1468957368}

没有刷新令牌,因为从谷歌获取refreshToken = null或需要设置null与键刷新令牌或此dos不metter?

    $isExpired = $client->isAccessTokenExpired(); // true (bool Returns True if the access_token …
Run Code Online (Sandbox Code Playgroud)

php google-drive-api google-api-php-client

4
推荐指数
3
解决办法
6644
查看次数

如何更正我的 postgres 图像中的 set work_mem amd max_wal_size

我想为我的 postgres 映像设置一些配置,需要增加 work_mem 和max_wal_size,但遇到错误

/usr/local/bin/docker-entrypoint.sh: line 315: exec: postgres -c max_wal_size=2GB -c work_mem=2GB: not found
Run Code Online (Sandbox Code Playgroud)

版本

Docker version 19.03.8, build afacb8b7f0
docker-compose version 1.23.1, build b02f1306
Run Code Online (Sandbox Code Playgroud)

和我的码头工人组成

version: '3'
services:

postgres:
    image: postgres:11-alpine
    shm_size: 5g
    command: postgres -c max_wal_size=2GB -c work_mem=2GB
    ports:
        - '5432:5432'
    container_name: 'postgresql_alpine'
    working_dir: /app
    restart: always
    environment:
        POSTGRES_DB: ${POSTGRES_DB}
        POSTGRES_USER: ${POSTGRES_USER}
        POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
        LC_COLLATE: 'sv_SE.UTF-8'
        LC_CTYPE: 'sv_SE.UTF-8'
    volumes:
        - ./data/postgresql:/var/lib/postgresql/data
    networks:
        - php
Run Code Online (Sandbox Code Playgroud)

和错误

ivan@ivan-laptop:~/hosts/docker-symfony$ docker logs d30c27661a48
/usr/local/bin/docker-entrypoint.sh: line 315: exec: postgres …
Run Code Online (Sandbox Code Playgroud)

postgresql docker docker-compose

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

Symfony 学说分页

我有实体用户,例如计数 90355,我需要得到 100 个用户并与这个用户做一些逻辑。然后接下来 100 次使用,这是我拥有的,但是当我找到所有服务器下拉列表时如何解决这个问题?

public function find()
{
    $developers = $this->em->getRepository('ArtelProfileBundle:Users')->findBy(array(), array('id' => 'desc'));
    foreach ($developers as $developer) {
       $this->getApiFullContact($developer);
    }
    return true;
}
Run Code Online (Sandbox Code Playgroud)

我想这个函数但是 setFirstResult 和 setMaxResults 动态变量?

    public function getPaginationUser()
{
    $qb = $this->getEntityManager()->createQueryBuilder('d');
    $qb
        ->select('d')
        ->from('ArtelProfileBundle:Users', 'd')
        ->setFirstResult(0)
        ->setMaxResults(100)
        ->orderBy('d.id', 'DESC')
        ->getQuery()
        ->getResult()
    ;
    $query = $qb->getQuery();
    $results = $query->getResult();

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

这个迭代怎么做?

php symfony doctrine-orm

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

Symfony在表单领域验证电话

我有表格现场电话的Symfony 2.6和个人信息表格,如rhis

+38 (918) 280-1594
Run Code Online (Sandbox Code Playgroud)

如果开发人员写"_"或更多数字,空格.我如何检查这个?喜欢开发者写

+38 (918) 2 801_594
Run Code Online (Sandbox Code Playgroud)

我在DB中设置了

+38(918)2801594
Run Code Online (Sandbox Code Playgroud)

解决这个问题的流程和决策或捆绑包是什么?

->add('telephone', null, array('label' => 'Telephone', 'max_length' => 255, 'required' => false));

$builder->get('telephone')->addModelTransformer(new CallbackTransformer(
    // transform <br/> to \n so the textarea reads easier
    function ($originalDescription) {
        return preg_replace('/[^0-9()]+/', "", $originalDescription);
    },
    function ($submittedDescription) {
        // remove most HTML tags (but not br,p)
        $cleaned = strip_tags($submittedDescription, '<br><br/><p>');
        // transform any \n to real <br/>
        return str_replace("\n", '<br/>', $cleaned);
    }
));
Run Code Online (Sandbox Code Playgroud)

但它是如何工作的?我写了电话65454 ###而这个"#"写在我的数据库中这是错的.为什么我不明白?我需要确定位数(12位数).也许请举例.

我发布了+30632666 $$#并在DB中设置了这个+30632666 $$#但是在形式上可见这个30632666这正是我需要在我的数据库中,我需要在数据库中设置正确的电话并限制13个字符 - 一个"+"和12个 - …

php mysql symfony doctrine-orm

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

Symfony 软删除

我有实体并且我使用

* @Gedmo\SoftDeleteable(fieldName="deletedAt")
Run Code Online (Sandbox Code Playgroud)

当我删除数据库中的某些实体时,我的实体和字段已删除。我有时间删除实体,这是可以的。但现在我需要找到所有deleteAt实体?我创建QB

$qb = $this->getEntityManager()->createQueryBuilder('d');
$qb
    ->select('d')
    ->from('ArtelProfileBundle:Project', 'd')
    ->where('d.deletedAt IS NOT NULL');

$count = $qb->getQuery()->getResult();
$query = $qb->getQuery();
$results = $query->getResult();
return [$results, $count];
Run Code Online (Sandbox Code Playgroud)

我有 0 个实体,为什么以及如何找到实体?

更新 在我的控制器中

class ProjectController extends FOSRestController
{
public function getProjectsAction(ParamFetcher $paramFetcher)
{
$manager = $this->getDoctrine()->getManager();
        if($paramFetcher->get('status'))
    {
        $manager->getFilters()->disable('soft-deleteable');
        $queryBuilder = $manager->getRepository('ArtelProfileBundle:Project')->findForStatusProject($paramFetcher, $this->getUser());
    }
Run Code Online (Sandbox Code Playgroud)

我有错误

 Filter 'soft-deleteable' is not enabled.
Run Code Online (Sandbox Code Playgroud)

我的实体

/**
 * Project
 *
 * @ORM\Table(name="project")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt")
 * @ORM\Entity(repositoryClass="Artel\ProfileBundle\Entity\Repository\ProjectRepository")
 * @ExclusionPolicy("all")
 */
class Project
{
/////
/**
 * @var …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

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

Symfony对用户有很多作用

我有问题,早期我的实体有一个角色,这对项目来说已经足够了.但是现在我的实体需要有很多角色,比如ROLE_DEVELOPER,ROLE_COMPANY,当用户为实体做一些操作时添加新角色.如何最好地解决这种情况,创建新实体或更改数组中的字段角色或什么?我在表用户中有实体,并且有一个ROLE_USER,现在用户想要创建团队,团队需要角色ROLE_TEAM,以及如何设置新角色?然后用户想要创建客户端实体,我需要设置ROLE_CLIENT.如果我创建ManyToMany关系我的用户,谁有多个角色身份验证?在用户配置文件中我想要创建,如果用户有ROLE_TEAM - 可见按钮用于转到配置文件团队,可以创建他的多个角色,我需要foreach数组角色?

/**
 * Users
 *
 * @ORM\Table(name="users")
 * @ORM\Entity(repositoryClass="Artel\ProfileBundle\Entity\UsersRepository")
 * @ExclusionPolicy("all")
 */

 class Users implements UserInterface
 {
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @Expose()
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * @Gedmo\Slug(fields={"firstName", "lastName"}, separator="-", updatable=true)
 * @ORM\Column(name="name", type="string", options={"default": "Company"}, length=255, nullable=false)
 * @Assert\Length(min=3, max=255)
 */
protected $username;

/**
 * @var string
 *
 * @ORM\Column(name="password", type="string", length=80, nullable=true)
 */
protected $password;

/**
 * @ORM\ManyToMany(targetEntity="Role")
 * @ORM\JoinTable(name="user_role",
 *     joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
 *     inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
 * …
Run Code Online (Sandbox Code Playgroud)

php security symfony doctrine-orm

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

如何在 Guzzle 中获取响应体

当我使用 Guzzle 发布请求时如何获得响应我使用"guzzle/guzzle": "^3.9", 我发布一些 url 请求并且我需要响应正文,但是使用 Guzzle 我没有发现这是响应,在使用标准 php 函数的地方file_get_contents我有响应正文。Guzzle het反应体如何?

$guzzle = new Client();
$postCell = $guzzle
    ->post($url, [], $addProtectedRangeJson)
    ->addHeader('Authorization', 'Bearer ' . $arrayAccessTokenClient)
    ->addHeader('Content-type', 'application/json')
;

$postCell
    ->send()
    ->getBody(true)
;

$contents = (string) $postCell->getBody(); // get body that I post -> my request, not response
$contents = $postCell->getBody()->getContents(); // not find getContents, ask me did you mean to call getContentMd5 
$answer = json_decode($postCell->getResponse()->getBody(), true);

return $answer;
Run Code Online (Sandbox Code Playgroud)

现在$answer

result = {Guzzle\Http\EntityBody} [7] …
Run Code Online (Sandbox Code Playgroud)

php guzzle

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