• Какой расширение выбрать для обрезация фотографий для yii2?

    @agent1156 Автор вопроса
    <?php if ($item->category == "ALANÆ LIFE"): ?>
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                    <article class="post img-thumbnail with-border post-list">
                                        <div class="post-holder">
                                            <div class="row">
                                                <div class="col-md-8">
                                                    <figure>
                                                        <a href="<?= Url::to(["/post/index", 'id' => $item->id]) ?>">
                                                            <?php if(empty($item->img)):?>
                                                            <?= Html::img("@backend/web/images/store/no-images.jpg")?></a>
                                                        <?php endif?>
                                                         <?php
                                                        $file=Yii::getAlias('@app/web/img/box3.jpg');
                                                        $image=Yii::$app->image->load($file);
    
                                                        echo    $image->resize(100,100);
                                                        ?>
                                                        <?= Html::img("@backend/web/images/store/{$item->img}") ?></a>
                                                        <ul class="post-meta">
    
                                                            <li>
                                                                <a href="<?= Url::to(["/post/index", 'id' => $item->id]) ?>">
                                                                    <em><?= mb_substr($item->date, 8, 2, 'UTF-8')?></em>
                                                                    <em>
                                                                        <?php
                                                                        $dateObj = \DateTime::createFromFormat('!m', mb_substr($item->date, 5, 2));
                                                                        echo mb_substr($dateObj->format('F'), 0, 3);
                                                                        ?>
                                                                    </em>
                                                                </a>
                                                            </li>
    
                                                        </ul>
                                                    </figure>
                                                </div>
                                                <div class="col-md-4">
                                                    <div class="post-head">
                                                        <h2>
                                                            <a href="<?= Url::to(["/post/index", 'id' => $item->id]) ?>">
                                                                <?php switch (Yii::$app->language): case"ru-RU": ?>
    
                                                                            <?= $item->title_ru ?>
                                                                            <?php break ?>
    
                                                                        <?php
                                                                case"en-US":
                                                                ?>
                                                                                <?= $item->title_en ?>
                                                                                <?php break ?>
    
                                                                            <?php
                                                                case
                                                                "ir-IR":
                                                                ?>
                                                                                <?= $item->title_ir ?>
                                                                                <?php break ?>
                                                                            <?php endswitch?>
                                                            </a></h2>
                                                    </div>
    
                                                    <div class="description">
                                                        <p>
                                                            <?php switch (Yii::$app->language): case"ru-RU": ?>
    
                                                                    <?= mb_substr('<p>' . $item->text_ru . '</p>', 0, 300, 'UTF-8') . ' <b>. . . </b>'; ?></p>
                                                        <?php break ?>
    
                                                                <?php
                                                        case"en-US":
                                                        ?>
                                                                    <?= mb_substr('<p>' . $item->text_en . '</p>', 0, 300, 'UTF-8') . ' <b>. . . </b>'; ?></p>
                                                        <?php break ?>
    
                                                                <?php
                                                        case
                                                        "ir-IR":
                                                        ?>
                                                                    <?= mb_substr('<p>' . $item->text_ir . '</p>', 0, 300, 'UTF-8') . ' <b>. . . </b>'; ?></p>
                                                        <?php break ?>
                                                                <?php endswitch?>
                                                        </p>
                                                    </div>
    Ответ написан
  • Как написать ссылку?

    @agent1156 Автор вопроса
    frontend
    <?php
    $params = array_merge(
        require(__DIR__ . '/../../common/config/params.php'),
        require(__DIR__ . '/../../common/config/params-local.php'),
        require(__DIR__ . '/params.php'),
        require(__DIR__ . '/params-local.php')
    );
    
    return [
        'id' => 'app-frontend',
        'basePath' => dirname(__DIR__),
        'bootstrap' => ['log'],
        'controllerNamespace' => 'frontend\controllers',
        'components' => [
    
    
            'urlManagerBack' => [
    
                'class' => 'yii\web\UrlManager',
                'baseUrl' => 'localhost/fashion-house',
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'rules' => require(__DIR__ . '/../../backend/config/main.php'), //тут путь к файлу с rules для backend
    
            ],
    
    
            'user' => [
                'identityClass' => 'common\models\User',
                'enableAutoLogin' => true,
            ],
            'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yii\log\FileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],
            'errorHandler' => [
                'errorAction' => 'site/error',
            ],
    
            'urlManager' => [
                'class' => 'yii\web\UrlManager',
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'rules' => [
    
    
                ],
            ],
    
    
    
        ],
    
    
    
        'params' => $params,
    ];


    backend

    <?php
    $params = array_merge(
        require(__DIR__ . '/../../common/config/params.php'),
        require(__DIR__ . '/../../common/config/params-local.php'),
        require(__DIR__ . '/params.php'),
        require(__DIR__ . '/params-local.php')
    );
    
    return [
        'id' => 'app-backend',
        'basePath' => dirname(__DIR__),
        'controllerNamespace' => 'backend\controllers',
        'bootstrap' => ['log'],
        'modules' => [],
        'components' => [
            'user' => [
                'identityClass' => 'common\models\User',
                'enableAutoLogin' => true,
            ],
            'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yii\log\FileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],
            'errorHandler' => [
                'errorAction' => 'site/error',
            ],
            
            'urlManager' => [
                'enablePrettyUrl' => true,
                'showScriptName' => false,
                'rules' => [
                ],
            ],
            
        ],
        'params' => $params,
    ];
    Ответ написан
  • Как настроить русскую коддировку?

    @agent1156 Автор вопроса
    #
    # The MySQL database server configuration file.
    #
    # You can copy this to one of:
    # - "/etc/mysql/my.cnf" to set global options,
    # - "~/.my.cnf" to set user-specific options.
    # 
    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
    # This will be passed to all mysql clients
    # It has been reported that passwords should be enclosed with ticks/quotes
    # escpecially if they contain "#" chars...
    # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
    
    # Here is entries for some specific programs
    # The following values assume you have at least 32M ram
    
    [mysqld_safe]
    socket		= /var/run/mysqld/mysqld.sock
    nice		= 0
    
    [mysqld]
    #
    # * Basic Settings
    #
    user		= mysql
    pid-file	= /var/run/mysqld/mysqld.pid
    socket		= /var/run/mysqld/mysqld.sock
    port		= 3306
    basedir		= /usr
    datadir		= /var/lib/mysql
    tmpdir		= /tmp
    lc-messages-dir	= /usr/share/mysql
    skip-external-locking
    #
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    bind-address		= 127.0.0.1
    #
    # * Fine Tuning
    #
    key_buffer_size		= 16M
    max_allowed_packet	= 16M
    thread_stack		= 192K
    thread_cache_size       = 8
    # This replaces the startup script and checks MyISAM tables if needed
    # the first time they are touched
    myisam-recover-options  = BACKUP
    #max_connections        = 100
    #table_cache            = 64
    #thread_concurrency     = 10
    #
    # * Query Cache Configuration
    #
    query_cache_limit	= 1M
    query_cache_size        = 16M
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    # As of 5.1 you can enable the log at runtime!
    #general_log_file        = /var/log/mysql/mysql.log
    #general_log             = 1
    #
    # Error log - should be very few entries.
    #
    log_error = /var/log/mysql/error.log
    #
    # Here you can see queries with especially long duration
    #log_slow_queries	= /var/log/mysql/mysql-slow.log
    #long_query_time = 2
    #log-queries-not-using-indexes
    #
    # The following can be used as easy to replay backup logs or for replication.
    # note: if you are setting up a replication slave, see README.Debian about
    #       other settings you may need to change.
    #server-id		= 1
    #log_bin			= /var/log/mysql/mysql-bin.log
    expire_logs_days	= 10
    max_binlog_size   = 100M
    #binlog_do_db		= include_database_name
    #binlog_ignore_db	= include_database_name
    #
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    #
    # * Security Features
    #
    # Read the manual, too, if you want chroot!
    # chroot = /var/lib/mysql/
    #
    # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
    #
    # ssl-ca=/etc/mysql/cacert.pem
    # ssl-cert=/etc/mysql/server-cert.pem
    # ssl-key=/etc/mysql/server-key.pem
    Ответ написан
  • Как сохранить картинку в yii2?

    @agent1156 Автор вопроса
    На локальном сервере Windows тоже могут быть закрыты права на запись?
    Ответ написан
  • Как удалить CRUD?

    @agent1156 Автор вопроса
    А как это сделать технически?
    Ответ написан
  • Yii2 метод actionDelete не работает, почему?

    @agent1156 Автор вопроса
    public function behaviors()
    {
    return [
    'verbs' => [

    'class' => VerbFilter::className(),
    'actions' => [
    'delete' => ['POST','GET'],
    ],
    ],
    ];
    }
    Ответ написан