2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-attachfile

Package for attaching files using ajax

image

syablonskiy/yii2-attachfile

Package for attaching files using ajax

  • Friday, July 6, 2018
  • by serega8989
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2-attachfile

Π”Π°Π½Π½Ρ‹ΠΉ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ ΠΏΡ€Π΅Π΄Π½Π°Π·Π½Π°Ρ‡Π΅Π½ для приклСплСния Ρ„Π°ΠΉΠ»Π°(ΠΎΠ²) ΠΊ модСлям ActiveRecord., (*1)

Установка

  1. УстановитС Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ Composer Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚Π΅ Π² Ρ‚Π΅Ρ€ΠΌΠΈΠ½Π°Π»Π΅ composer require syablonskiy/yii2-attachfile "^1" Π»ΠΈΠ±ΠΎ Π΄ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ Π² ΡΠ΅ΠΊΡ†ΠΈΡŽ require Π² Ρ„Π°ΠΉΠ»Π΅ composer.json "syablonskiy/yii2-attachfile": "^1", (*2)

  2. Π”ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ ΠΌΠΎΠ΄ΡƒΠ»ΡŒ Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡŽ вашСго web-прилоТСния, (*3)

'modules' => [
        ...
        'attachfile' => [
            'class' => syablonskiy\attachfile\Module::className(),
            'storePath' => 'path/to/upload/folder', //default '@app/uploads'
            'rules' => [
                'extensions' => 'jpg, zip, mp4',
                'maxSize' => 1024*1024,
            ],
            'maxFiles' => 2, //default  '3'
            'tableName' => 'your_table_name', //default 'attachment'
        ],
        ...
]
  1. Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚Π΅ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΡŽ php yii migrate --migrationPath=@syablonskiy/attachfile/migrations, (*4)

  2. ΠŸΡ€ΠΈΠΊΡ€Π΅ΠΏΠΈΡ‚Π΅ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΊ вашСй ActiveRecord ΠΌΠΎΠ΄Π΅Π»ΠΈ, (*5)

    public function behaviors()
    {
        return [
           \syablonskiy\attachfile\behaviors\AttachmentBehavior::className()
        ];
    }
  1. Π£Π΄Π°Π»Π΅Π½ΠΈΠ΅ Π½Π΅Π°ΠΊΡ‚ΡƒΠ°Π»ΡŒΠ½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ² Π’ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡŽ консольного прилоТСния Π΄ΠΎΠ±Π°Π²ΡŒΡ‚Π΅
'modules' => [
        ...
        'attachfile' => [
            'class' => syablonskiy\attachfile\Module::className(),
            'controllerNamespace' => 'syablonskiy\attachfile\commands',
        ],
        ...
]

И Π΄ΠΎΠ±Π°Π²ΡŒΡ‚Π΅ Π² ΠΏΠ»Π°Π½ΠΈΡ€ΠΎΠ²Ρ‰ΠΈΠΊ Cron ΠΏΠΎΠ΄ΠΎΠ±Π½ΡƒΡŽ строку */30 * * * * cd /path/to/your/app && /usr/bin/php yii attachfile/cron/delete-files >/dev/null ПослС этого ΠΊΠ°ΠΆΠ΄Ρ‹Π΅ полчаса Π±ΡƒΠ΄ΡƒΡ‚ ΡƒΠ΄Π°Π»ΡΡ‚ΡŒΡΡ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½Π½Ρ‹Π΅, Π½ΠΎ Π½Π΅ΠΏΡ€ΠΈΠΊΡ€Π΅ΠΏΠ»Π΅Π½Π½Ρ‹Π΅ ΠΊ ΠΌΠΎΠ΄Π΅Π»ΠΈ Ρ„Π°ΠΉΠ»Ρ‹., (*6)

ИспользованиС

  1. Для прикрСплСния Ρ„Π°ΠΉΠ»ΠΎΠ², ΠΊ создаваСмой ΠΌΠΎΠ΄Π΅Π»ΠΈ, ΠΏΠ΅Ρ€Π΅Π΄Π°ΠΉΡ‚Π΅ Π² Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ экзСмпляр [[yii\widgets\ActiveForm]]
<?= \syablonskiy\attachfile\widgets\InputWidget::widget(['form' => $form]) ?>
  1. ΠžΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ ΠΏΡ€ΠΈΠΊΡ€Π΅ΠΏΠ»Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ² ΠΌΠΎΠ΄Π΅Π»ΠΈ $model
<?= \syablonskiy\attachfile\widgets\FilesListWidget::widget(
        [
            'model' => $model,
            'allowDeletion' => true //default 'false'
        ]
    ) ?>

ΠžΠΏΡ†ΠΈΡ 'allowDeletion' добавляСт Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΎΡ‚ΠΌΠ΅Ρ‡Π°Ρ‚ΡŒ Ρ„Π°ΠΉΠ»Ρ‹ для удалСния, (*7)

The Versions

06/07 2018

dev-master

9999999-dev

Package for attaching files using ajax

  Sources   Download

MIT

The Requires

 

by Sergey Yablonskiy

06/07 2018

1.0

1.0.0.0

Package for attaching files using ajax

  Sources   Download

MIT

The Requires

 

by Sergey Yablonskiy