PHPackages                             lucasguo/yii2-import - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. lucasguo/yii2-import

ActiveYii2-extension[PDF &amp; Document Generation](/categories/documents)

lucasguo/yii2-import
====================

Simple import module for yii2 framework

0.1.1(9y ago)25.6k↓100%6BSD-3-ClausePHP

Since Nov 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lucasguo/yii2-import)[ Packagist](https://packagist.org/packages/lucasguo/yii2-import)[ Docs](https://github.com/lucasguo/yii2-import/)[ RSS](/packages/lucasguo-yii2-import/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

yii2-import
===========

[](#yii2-import)

Yii2-import is an extension for Yii Framework. It helps you transfer file into models. Currently support Excel format only. But it's easily to extend to support your file.

Installation
------------

[](#installation)

You can use composer to install this extension by:

- run

```
$ php composer.phar require lucasguo/yii2-import "*"

```

- or add

```
"lucasguo/yii2-import": "*"

```

to your composer.json and then execute 'composer update'.

Usage
-----

[](#usage)

Assume there is a model class

```
class Post extends Model
{
	const STATUS_NEW = 0;
	const STATUS_APPROVED = 1;

	public $title;
	public $status;
	public $content;

	public static function getStatusList()
	{
		return [
			self::STATUS_NEW = 'New',
			self::STATUS_APPROVED = 'Approved',
		];
	}
}
```

And the form and view as below.

```
class ImportForm extends Model
{
	public $file;

	public function rules()
	{
		return [
			['file', 'file', 'skipOnEmpty' => false, 'extensions' => 'xlsx'],
		];
	}
}
```

```
