$this->render('another_template',['prop'=>$val]);//шаблон в этой же директории
$this->renderFile('@app/some/path/views/another_template',['prop'=>$val]);//шаблон из другого места
<?php $this->beginContent('@app/views/layouts/base.php'); ?>
//Some another content - внедрение в вывод контента вызываемого layout
<?php $this->endContent(); ?>
interface PostCommentModelInterface // можно extends ActiveRecordInterface
{
/**
* @return ActiveRecord[]|Comment[]
**/
public function findForPost();
}
class Model extends yii\base\Model
{
protected $commentModel;
public function __construct(PostCommentModelInterface $commentModel, $config = [])
{
$this->commentModel = $commentModel;
parent::__construct($config);
}
]
...
protected $commentModel;
public function __construct(\yii\container\Container $container, $config = [])
{
$this->commentModel = $container->get('\app\modules\posts\PostCommentModelInterface'');
parent::__construct($config);
}
...
FROM php:7.0-fpm
ENV DEBIAN_FRONTEND noninteractive
#####################################
# Add configuration files
#####################################
COPY php7/files /
#####################################
# Non-Root User:
#####################################
ARG PUID=1000
ARG PGID=1000
RUN groupadd -r -g $PGID udocker && \
useradd -r -u $PUID -g udocker -m udocker
ENV PHP_USER_ID=33 \
HOME=/home/udocker \
PATH=/var/www/App:/var/www/App/vendor/bin:$HOME/.composer/vendor/bin:$PATH \
TERM=linux
#####################################
# Install system packages :
#####################################
RUN apt-get update && apt-get -y install \
git \
openssl\
libssh2-1-dev\
libssh2-php\
libssl-dev \
libxml2-dev \
libicu-dev \
libmcrypt-dev \
libfreetype6-dev \
libjpeg-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
zlib1g-dev \
mysql-client \
openssh-client \
libxml2-dev \
libpq-dev \
nano \
yui-compressor \
linkchecker \
librabbitmq-dev \
nodejs \
--no-install-recommends
#####################################
# Install PHP extensions :
#####################################
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ && \
docker-php-ext-configure bcmath && \
docker-php-ext-install gd \
iconv\
intl \
pdo \
pdo_mysql \
pdo_pgsql \
mbstring \
mcrypt \
zip \
bcmath \
soap \
opcache
ENV RABBITMQ_C_VERSION 0.7.1
RUN curl -L -o /tmp/rabbitmq.tar.gz https://github.com/alanxz/rabbitmq-c/releases/download/v$RABBITMQ_C_VERSION/rabbitmq-c-$RABBITMQ_C_VERSION.tar.gz \
&& tar xfz /tmp/rabbitmq.tar.gz \
&& rm -r /tmp/rabbitmq.tar.gz \
&& cd rabbitmq-c-$RABBITMQ_C_VERSION \
&& ./configure \
&& make \
&& make install
#собссно тоже костыли
RUN if [ -z `php -m | grep -i "amqp"` ];then \
pecl install amqp && docker-php-ext-enable amqp \
;fi
RUN if [ -z `php -m | grep -i "redis"` ]; then \
pecl install redis && docker-php-ext-enable redis \
;fi
#####################################
# Composer:
#####################################
RUN curl -s http://getcomposer.org/installer | php && \
mv composer.phar /usr/local/bin/composer
COPY php7/composer.json /home/udocker/.composer/composer.json
COPY php7/auth.json /home/udocker/.composer/auth.json
#ENV GITHUB_API_TOKEN ${GITHUB_API_TOKEN}
#RUN sed -i "s/GITHUB_API_TOKEN/$GITHUB_API_TOKEN/g" /home/udocker/.composer/auth.json
RUN chown -R udocker:udocker /home/udocker/.composer
USER udocker
RUN composer global install --prefer-dist && composer global dumpautoload --optimize
#####################################
# Node / NVM:
#####################################
USER root
# Check if NVM needs to be installed
ARG INSTALL_NODE=true
ENV INSTALL_NODE ${INSTALL_NODE}
RUN if [ ${INSTALL_NODE} = true ]; then \
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash \
;fi
ENV if [ ${INSTALL_NODE} = true ]; then \
# Set the ENV
NVM_DIR=/home/udocker/.nvm \
# Install NodeJS with NVM
RUN . ~/.nvm/nvm.sh && \
nvm install stable && \
nvm use stable && \
nvm alias stable && \
npm install -g gulp bower \
;fi
# Wouldn't execute when added to the RUN statement in the above block
# Source NVM when loading bash since ~/.profile isn't loaded on non-login shell
RUN if [ ${INSTALL_NODE} = true ]; then \
echo "" >> ~/.bashrc && \
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc \
;fi
#####################################
# CLEAN UP:
#####################################
USER root
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /var/www/App
CMD ["docker-run.sh"]
version: '2'
services:
app:
image: php:7.0-fpm
volumes:
- ./App:/var/www/App
command: "true"
restart: always
nginx:
build: ./dockerconf/nginx/
ports:
- 8001:80
links:
- php
volumes_from:
- app
php:
build:
dockerfile: php7/Dockerfile-fpm
context: 'dockerconf'
links:
- redis
- postgres
environment:
- GITHUB_API_TOKEN="${GITHUB_API_TOKEN}"
- INSTALL_NODE="${INSTALL_NODE}"
expose:
- 9000
volumes_from:
- app
volumes:
- ./dockerdata/logs/nginx:/var/log/nginx
redis:
image: redis:latest
ports:
- "6300:6379"
volumes:
- ./dockerdata/redis:/var/lib/redis
- ./dockerdata/logs/redis:/var/log/redis
restart: always
postgres:
build: ./dockerconf/postgres
volumes:
- ./dockerdata/pgsql:/var/lib/postgresql
- ./dockerdata/logs/pgsql:/var/log/postgresql
ports:
- "5400:5432"
environment:
- POSTGRES_DB=pgdb
- POSTGRES_USER=pguser
- POSTGRES_PASSWORD=pgpass
like: operand 1 should be a column or DB expression, and operand 2 be a string or an array representing the values that the column or DB expression should be like. For example, ['like', 'name', 'tester'] will generate name LIKE '%tester%'. When the value range is given as an array, multiple LIKE predicates will be generated and concatenated using AND. For example, ['like', 'name', ['test', 'sample']] will generate name LIKE '%test%' AND name LIKE '%sample%'. The method will properly quote the column name and escape special characters in the values. Sometimes, you may want to add the percentage characters to the matching value by yourself, you may supply a third operand false to do so. For example, ['like', 'name', '%tester', false] will generate name LIKE '%tester'.
or like: similar to the like operator except that OR is used to concatenate the LIKE predicates when operand 2 is an array.
not like: similar to the like operator except that LIKE is replaced with NOT LIKE in the generated condition.
or not like: similar to the not like operator except that OR is used to concatenate the NOT LIKE predicates.
public function actionSearch($query)
{
$subqueries = preg_split("/\s/u", $query, -1, PREG_SPLIT_NO_EMPTY);
//Лучше потом отфильровать $subqueries убрав короткие слова или пошаманить с регуляркой что разбивало только если за пробелом слово больше n символов (чтоб Елизавета X так и осталась Елизавета X)
// например так
// $subqueries = preg_split("/\s(?=\w{2,})/u", $query, -1, PREG_SPLIT_NO_EMPTY)
$search = Serial::find()->where(['or',['like', 'name_serial', $subqueries],['like', 'description_serial', $subqueries]]);
$searchDataprovider = new ActiveDataProvider([
'query' => $search,
'pagination' => [
'pageSize' => 15,
],
]);
return $this->render('search', [
'searchDataprovider' => $searchDataprovider
]);
}
Есть компонент по типу gridview.
Весь js находится в vendor/component/panel
SomeGridWidget::widget([
'prop1'=>'val1',
'prop2'=>'val2',
'clientOptions'=>[
'onSomeEventCallback'=>new JsExpression('
function(callback_arguments){do_custom_behaviors();}
'),
]
]);
Но почему-то не видит методы find. Не могу понять, почему.
'db'=>[
'class' => 'yii\db\Connection',
.....
'schemaMap' => [
'pgsql' => [
'class' => 'yii\db\pgsql\Schema',
'defaultSchema' => 'myschema', //specify your schema here
]
],
'on afterOpen' => function ($event) {
$event->sender->createCommand("SET search_path TO myschema")->execute();
}
]
$result = [];
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
foreach($dataProvider->models as $model){
$result[$model->year][] = $model;
}
return $this->render('index', [
'searchModel' => $searchModel,
'result' => $result,
]);
<?php foreach($result as $year=>$models):?>
<h3><?=$year?></h3>
<?php foreach($models as $model):?>
<?=$model->data?>
<?php endforeach?>
<?php endforeach?>