我需要在Dockerfile中设置默认时区.我有两个容器(nginx和php7-fpm).
当我进入PHP容器的bash并运行时,php --info | grep timezone我得到:
默认时区=> UTC
date.timezone =>没有值=>没有值
我的dockerfiles如下:
nginx的/ Dockerfile:
FROM debian:jessie
RUN apt-get update && apt-get install -y nginx
ADD nginx.conf /etc/nginx/
ADD site.conf /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site
RUN rm /etc/nginx/sites-enabled/default
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
RUN usermod -u 1000 www-data
CMD ["nginx"]
EXPOSE 80
EXPOSE 443
Run Code Online (Sandbox Code Playgroud)
PHP-FPM/Dockerfile:
FROM php:7.0-fpm
RUN apt-get update && apt-get install -y git unzip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin …Run Code Online (Sandbox Code Playgroud) 我正在尝试为使用全局参数(来自YML文件)的服务编写测试。
我正在方法中检索此参数setUp(),但是当我尝试在中使用它们时@dataProvider,会引发错误。
class InterpreterServiceTest extends KernelTestCase
{
private $container;
private $service;
private $citiesMap;
public function setUp()
{
self::bootKernel();
$this->container = self::$kernel->getContainer();
$this->service = $this->container->get('geolocation.interpreter');
$this->citiesMap = $this->container->getParameter("citiesmap");
self::tearDown();
}
/**
* @dataProvider locationsProvider
*/
public function testCompanyCityFromCity($location, $expected)
{
$city = $this->service->getCompanyCityFromCity($location);
$this->assertEquals($expected, $city);
}
public function locationsProvider()
{
$return = array();
foreach ($this->citiesMap as $area) {
$return[] = [
$area['external_service_area'],
$area['company_area']
];
}
return $return;
}
}
Run Code Online (Sandbox Code Playgroud)
为foreach()提供了无效的参数
如果我手动写的返回locationsProvider()它的作品
return [
["Barcelona", "Barcelona"], …Run Code Online (Sandbox Code Playgroud) 我正在使用Docker和Docker-compose来构建一堆nginx + php.
我正在尝试在我的.env文件中设置时区并在Dockerfile中使用它,但我可能会误解文档中的内容.
.ENV
# Timezone
TIMEZONE=Europe/Madrid
Run Code Online (Sandbox Code Playgroud)
泊坞窗,compose.yml
version '2'
services:
php:
build: php7-fpm
volumes:
- ${APP_PATH}:/var/www/app
- ./logs:/var/www/logs
environment:
TIMEZONE: ${TIMEZONE}
#[...more.stuff...]
Run Code Online (Sandbox Code Playgroud)
PHP7-FPM/Dockerfile
FROM php:7.0-fpm
ARG TIMEZONE
#[...more.stuff...]
ENV TIMEZONE=${TIMEZONE}
RUN ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime && echo $TIMEZONE > /etc/timezone
RUN printf '[PHP]\ndate.timezone = "%s"\n', $TIMEZONE > /usr/local/etc/php/conf.d/tzone.ini
Run Code Online (Sandbox Code Playgroud)
容器内部没有正确设置时区(php --info | grep timezone在php容器bash中运行).如果我在Dockerfile中手动编写区域,它可以工作.
我正在 Windows 10 上使用 Laragon 本地开发 Laravel 项目
PHP版本:7.1.8 64位NTS
我知道的相关 php.ini 是
post_max_size = 8M
文件上传=开
源代码:
// if no image uploaded
if (!$request->hasFile('profile_picture'))
throw new \Exception("No image found");
// get uploaded image
$image = $request->file('profile_picture');
// store to storage/app/users/
Storage::putFileAs('users', $image ,auth()->id());
Run Code Online (Sandbox Code Playgroud)
在我看来,这是服务器配置问题,可能是 php.ini 上的问题,
但我对服务器配置不熟悉,网上与此问题相关的主题并不多。
我知道问题原因,但不知道如何解决。
我需要在 Codeigniter 中构建此查询,但我不知道如何获得 SUM 的结果:
SELECT
description, SUM(amount)
FROM
PAYMENT
WHERE
(date_payment between '2014-02-01 00:00:00' AND '2014-02-28 23:59:59')
GROUP BY description;
Run Code Online (Sandbox Code Playgroud)
我试图得到这样的结果:
$qwer = $this->db->query("
SELECT description, SUM(amount)
FROM PAYMENT
WHERE (date_payment between '$min_date' AND '$max_date')
GROUP BY description;");
$i = 0;
foreach ($qwer->result() as $payment) {
$det_payment[$i] = array(
'description'=>$payment->description,
'amount'=>$payment->amount
);
$i++;
}
Run Code Online (Sandbox Code Playgroud)
当然 "$payment->amount" 是错误的,但是如果我为 SUM 使用别名,则该模型不起作用。
编辑:现在我可以在描述或总和之间进行选择,但我不能同时使用 select 和 select_sum
$this->db->select('description');
//$this->db->select_sum('amount', 'amount');
$this->db->where('date_payment >=', $min_fecha);
$this->db->where('date_payment <=', $max_fecha);
$this->db->group_by("description");
$qwer = $this->db->get('PAYMENT');
Run Code Online (Sandbox Code Playgroud) 我想在Symfony中使用Fos UserBundle.
我将其配置为Symfony Doc的"FOSUserBundle入门".
/ Login页面正在工作,但当我打开/ register页面时,我得到错误:
尝试从命名空间"AppBundle\Entity"加载类"User".您是否忘记了"使用"语句,例如"Symfony\Component\Security\Core\User\User","Symfony\Bridge\Doctrine\Tests\Fixtures\User"或"FOS\UserBundle\Model\User"?
500 Internal Server Error - ClassNotFoundException
Stack Trace
1. in vendor\friendsofsymfony\user-bundle\Model\UserManager.php at line 40
37. public function createUser()
38. {
39. $class = $this->getClass();
40. $user = new $class();
41.
42. return $user;
43. }
2. at UserManager ->createUser ()
Run Code Online (Sandbox Code Playgroud)
我已经清除了缓存:
php app/console cache:clear --env=prod --no-warmup
php app/console cache:clear --env=dev --no-warmup
Run Code Online (Sandbox Code Playgroud)
并使作曲家更新,但没有发生.
版本:
FOS /用户捆绑:v2.0.0
Symfony:v2.8.18
PHP:7.1.2
Twig:v2.3.0
这是我的用户级:
namespace AppBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* web_user …Run Code Online (Sandbox Code Playgroud) php ×3
docker ×2
dockerfile ×2
symfony ×2
activerecord ×1
codeigniter ×1
laravel ×1
nginx ×1
phpunit ×1