我想链接2个单独的容器:
问题是PHP脚本不起作用.也许php-fpm配置不正确.这是源代码,位于我的存储库中.这是文件docker-compose.yml:
nginx:
build: .
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www/test/
links:
- fpm
fpm:
image: php:fpm
ports:
- "9000:9000"
Run Code Online (Sandbox Code Playgroud)
和Dockerfile我使用了基于nginx的一个建立一个自定义图像:
FROM nginx
# Change Nginx config here...
RUN rm /etc/nginx/conf.d/default.conf
ADD ./default.conf /etc/nginx/conf.d/
Run Code Online (Sandbox Code Playgroud)
最后,这是我的自定义Nginx虚拟主机配置:
server {
listen 80;
server_name localhost;
root /var/www/test;
error_log /var/log/nginx/localhost.error.log;
access_log /var/log/nginx/localhost.access.log;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php(/|$) {
fastcgi_pass 192.168.59.103:9000;
fastcgi_split_path_info …Run Code Online (Sandbox Code Playgroud) 我尝试使用一个简单的循环,在我的实际代码中这个循环更复杂,我需要break这样的迭代,如:
{% for post in posts %}
{% if post.id == 10 %}
{# break #}
{% endif %}
<h2>{{ post.heading }}</h2>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我如何使用的行为,break或continue在枝杈PHP控制结构?
我尝试用正确的APP_ID,APP_SECRET等发送curl请求到
https://oauth.vk.com/access_token?client_id=APP_ID&client_secret=APP_SECRET&code=7a6fa4dff77a228eeda56603b8f53806c883f011c40b72630bb50df056f6479e52a&redirect_uri=REDIRECT_URI
Run Code Online (Sandbox Code Playgroud)
我需要从它获取access_token,但得到一个FALSE并curl_error()打印下一条消息,否则:
60: SSL certificate problem: self signed certificate in certificate chain
Run Code Online (Sandbox Code Playgroud)
我的代码是:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
if ( ! $output) {
print curl_errno($ch) .': '. curl_error($ch);
}
// close curl resource to free up system resources
curl_close($ch);
return $output;
Run Code Online (Sandbox Code Playgroud)
当我手动移动到上面的链接时,我得到了access_token.为什么它不适用于卷曲?请帮忙.
我想配置我的PhpStorm IDE以在我的Docker容器中运行PHPUnit测试.
似乎我只能使用本地PHP可执行文件,或者通过SSH作为测试的解释器.
我可以在我的PHP容器上安装SSH服务,但它似乎是一个hacky解决方案,并且在线文章不鼓励在容器上安装SSH服务.
为了尝试让本地解释器工作,我尝试创建一个bash脚本来代理容器内对PHP的调用,如下所示:
#!/usr/bin/env bash
# Run PHP through Docker
docker exec -t mycontainer_php_1 php "$@"
Run Code Online (Sandbox Code Playgroud)
当我自己运行它时,这非常有效,但当我将PhpStorm指向它作为本地PHP解释器时,它不会将其识别为有效的PHP可执行文件.
那么什么是让这个工作的好方法?
我有一个repo,由子目录中的一些文件和一个Symfony项目组成.
如何仅在我的存储库子目录中的Symfony项目中使用Travis构建?
我正在研究一个Symfony2项目,我决定使用KNPPaginatorBundle构建一个简单的分页系统.所以我创建了一个Product实体,我想将paginator添加到indexAction动作(由CRUD命令生成).
// Retrieving products.
$em = $this->getDoctrine()->getManager();
//$entities = $em->getRepository('LiveDataShopBundle:Product')->findAll();
$dql = "SELECT a FROM LiveDataShopBundle:Product a";
$entities = $em->createQuery($dql);
// Creating pagnination
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$entities,
$this->get('request')->query->get('page', 1),
20
);
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我想使用产品的存储库,而不是直接在控制器中创建查询.我怎样才能做到这一点 ?实际上,直接将结果集合添加到paginate对象的速度太慢,因为它加载所有产品然后对ArrayCollection进行分页.
提前致谢.
K4
我手动生成表单的请求内容,并希望设置如下数据:
form[1][]=2&form[2][]=3&form[3][]=5&form[4][]=8&form[apply]=
Run Code Online (Sandbox Code Playgroud)
Symfony Request对象有一个getContent()方法,但没有setContent().
如何设置内容?
[Syntax Error] line 0, col 81: Error: Expected Literal, got 'NULL'当我尝试通过查询构建器执行查询时出错
$qb = $this->createQueryBuilder('r')
->select('r')
->where('r.query = :query')
->setParameter('query', $query)
->andWhere('r.lang = NULL')
;
return $qb->getQuery()->getOneOrNullResult();
Run Code Online (Sandbox Code Playgroud)
r.lang 字段定义为:
/**
* @var integer
*
* @ORM\ManyToOne(targetEntity="\BW\LocalizationBundle\Entity\Lang")
* @ORM\JoinColumn(name="lang_id", referencedColumnName="id")
*/
private $lang;
Run Code Online (Sandbox Code Playgroud)
请帮忙解决错误
我使用Symfony标准版并试图让Symfony Finder组件像服务一样,但没有找到它.要使用Finder,我需要手动创建它,如:
$finder = new Symfony\Component\Finder\Finder();
Run Code Online (Sandbox Code Playgroud)
为什么我无法从服务容器中获取它?这是错的吗?
PS Symfony Filesystem组件存在于服务容器中,并按名称提供filesystem.
php symfony symfony-components symfony-filesystem symfony-finder
我不能配置Nginx与php-fpm正确.当我得到任何PHP脚本时,我404 Not found在浏览器中收到Nginx 错误:
File not found.
Run Code Online (Sandbox Code Playgroud)
在我的php-fpm日志中,我得到:
172.17.42.1 - 28/Apr/2015:09:15:15 +0000 "GET /index.php" 404
Run Code Online (Sandbox Code Playgroud)
任何PHP脚本调用和Nginx日志我得到:
[error] 28105#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.168.66.66:9000", host: "localhost"
Run Code Online (Sandbox Code Playgroud)
我的Nginx vitualhost配置是:
server {
listen 80;
root /var/www/html;
index index.html;
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back …Run Code Online (Sandbox Code Playgroud) php ×7
symfony ×6
docker ×3
nginx ×2
break ×1
curl ×1
dockerfile ×1
doctrine-orm ×1
for-loop ×1
knppaginator ×1
oauth ×1
pagination ×1
phpstorm ×1
phpunit ×1
request ×1
travis-ci ×1
twig ×1
virtualhost ×1
vk ×1