diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000000..c0564c23fb --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,4 @@ +service_name: travis-ci +src_dir: framework/yii +coverage_clover: tests/unit/runtime/coveralls/clover.xml +json_path: tests/unit/runtime/coveralls/coveralls-upload.json \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..818cb6aa23 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +# Autodetect text files +* text=auto + +# ...Unless the name matches the following overriding patterns + +# Definitively text files +*.php text +*.css text +*.js text +*.txt text +*.md text +*.xml text +*.json text +*.bat text +*.sql text +*.xml text +*.yml text + +# Ensure those won't be messed up with +*.png binary +*.jpg binary +*.gif binary +*.ttf binary diff --git a/.travis.yml b/.travis.yml index 94769dbced..41bd6a95ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,14 @@ php: services: - redis-server -env: - - DB=mysql - before_script: - - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS yiitest;'; fi" + - composer self-update && composer --version + - composer require satooshi/php-coveralls 0.6.* + - mysql -e 'CREATE DATABASE yiitest;'; + - psql -U postgres -c 'CREATE DATABASE yiitest;'; -script: phpunit +script: + - phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml + +after_script: + - php vendor/bin/coveralls diff --git a/README.md b/README.md index 54bd49962c..1cd0121567 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,24 @@ If you are looking for a production-ready PHP framework, please use Yii 2.0 is still under heavy development. We may make significant changes without prior notices. **Yii 2.0 is not ready for production use yet.** -[](http://travis-ci.org/yiisoft/yii2) +[](https://packagist.org/packages/yiisoft/yii2) +[](https://packagist.org/packages/yiisoft/yii2) +[](http://travis-ci.org/yiisoft/yii2) +[](https://www.versioneye.com/php/yiisoft:yii2/dev-master) DIRECTORY STRUCTURE ------------------- apps/ ready-to-use Web apps built on Yii 2 - bootstrap/ a simple app supporting user login and contact page + advanced/ advanced app template with complex features + basic/ a simple app supporting user login and contact page + benchmark/ app demonstrating the minimal overhead introduced by the framework build/ internally used build tools docs/ documentation - yii/ framework source files + extensions/ extensions + framework/ framework files + yii/ framework source files tests/ tests of the core framework code diff --git a/apps/advanced/.gitignore b/apps/advanced/.gitignore new file mode 100644 index 0000000000..19dfc06dbc --- /dev/null +++ b/apps/advanced/.gitignore @@ -0,0 +1,2 @@ +/yii +/composer.lock \ No newline at end of file diff --git a/apps/bootstrap/LICENSE.md b/apps/advanced/LICENSE.md similarity index 100% rename from apps/bootstrap/LICENSE.md rename to apps/advanced/LICENSE.md diff --git a/apps/advanced/README.md b/apps/advanced/README.md new file mode 100644 index 0000000000..7055360446 --- /dev/null +++ b/apps/advanced/README.md @@ -0,0 +1,114 @@ +Yii 2 Advanced Application Template +=================================== + +**NOTE** Yii 2 and the relevant applications and extensions are still under heavy +development. We may make significant changes without prior notices. Please do not +use them for production. Please consider using [Yii v1.1](https://github.com/yiisoft/yii) +if you have a project to be deployed for production soon. + + +Thank you for using Yii 2 Advanced Application Template - an application template +that works out-of-box and can be easily customized to fit for your needs. + +Yii 2 Advanced Application Template is best suitable for large projects requiring frontend and backend separation, +deployment in different environments, configuration nesting etc. + + +DIRECTORY STRUCTURE +------------------- + +``` +common + config/ contains shared configurations + models/ contains model classes used in both backend and frontend +console + config/ contains console configurations + controllers/ contains console controllers (commands) + migrations/ contains database migrations + models/ contains console-specific model classes + runtime/ contains files generated during runtime +backend + assets/ contains application assets such as JavaScript and CSS + config/ contains backend configurations + controllers/ contains Web controller classes + models/ contains backend-specific model classes + runtime/ contains files generated during runtime + views/ contains view files for the Web application + web/ contains the entry script and Web resources +frontend + assets/ contains application assets such as JavaScript and CSS + config/ contains frontend configurations + controllers/ contains Web controller classes + models/ contains frontend-specific model classes + runtime/ contains files generated during runtime + views/ contains view files for the Web application + web/ contains the entry script and Web resources +vendor/ contains dependent 3rd-party packages +environments/ contains environment-based overrides +``` + + + +REQUIREMENTS +------------ + +The minimum requirement by Yii is that your Web server supports PHP 5.3.?. + +In order for captcha to work you need either GD2 extension or ImageMagick PHP extension. + +INSTALLATION +------------ + +### Install via Composer + +If you do not have [Composer](http://getcomposer.org/), you may download it from +[http://getcomposer.org/](http://getcomposer.org/) or run the following command on Linux/Unix/MacOS: + +~~~ +curl -s http://getcomposer.org/installer | php +~~~ + +You can then install the application using the following command: + +~~~ +php composer.phar create-project --stability=dev yiisoft/yii2-app-advanced yii-advanced +~~~ + + +### Install from an Archive File + +This is not currently available. We will provide it when Yii 2 is formally released. + + +### Install from development repository + +If you've cloned the [Yii 2 framework main development repository](https://github.com/yiisoft/yii2) you +can bootstrap your application with: + +~~~ +cd yii2/apps/advanced +php composer.phar create-project +~~~ + +*Note: If the above command fails with `[RuntimeException] Not enough arguments.` run +`php composer.phar self-update` to obtain an updated version of composer which supports creating projects +from local packages.* + + +GETTING STARTED +--------------- + +After you install the application, you have to conduct the following steps to initialize +the installed application. You only need to do these once for all. + +1. Execute the `init` command and select `dev` as environment. +2. Create a new database. It is assumed that MySQL InnoDB is used. If not, adjust `console/migrations/m130524_201442_init.php`. +3. In `common/config/params.php` set your database details in `components.db` values. + +Now you should be able to access: + +- the frontend using the URL `http://localhost/yii-advanced/frontend/web/` +- the backend using the URL `http://localhost/yii-advanced/backend/web/` + +assuming `yii-advanced` is directly under the document root of your Web server. + diff --git a/apps/bootstrap/assets/.gitignore b/apps/advanced/backend/assets/.gitkeep similarity index 100% rename from apps/bootstrap/assets/.gitignore rename to apps/advanced/backend/assets/.gitkeep diff --git a/apps/advanced/backend/config/.gitignore b/apps/advanced/backend/config/.gitignore new file mode 100644 index 0000000000..20da318cb2 --- /dev/null +++ b/apps/advanced/backend/config/.gitignore @@ -0,0 +1,2 @@ +main-local.php +params-local.php \ No newline at end of file diff --git a/apps/advanced/backend/config/AppAsset.php b/apps/advanced/backend/config/AppAsset.php new file mode 100644 index 0000000000..90a850d267 --- /dev/null +++ b/apps/advanced/backend/config/AppAsset.php @@ -0,0 +1,28 @@ + + * @since 2.0 + */ +class AppAsset extends AssetBundle +{ + public $basePath = '@webroot'; + public $baseUrl = '@web'; + public $css = array( + 'css/site.css', + ); + public $js = array( + ); + public $depends = array( + 'yii\web\YiiAsset', + 'yii\bootstrap\BootstrapAsset', + ); +} diff --git a/apps/advanced/backend/config/main.php b/apps/advanced/backend/config/main.php new file mode 100644 index 0000000000..377d34c373 --- /dev/null +++ b/apps/advanced/backend/config/main.php @@ -0,0 +1,36 @@ + 'app-backend', + 'basePath' => dirname(__DIR__), + 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', + 'preload' => array('log'), + 'controllerNamespace' => 'backend\controllers', + 'modules' => array( + ), + 'components' => array( + 'db' => $params['components.db'], + 'cache' => $params['components.cache'], + 'user' => array( + 'class' => 'yii\web\User', + 'identityClass' => 'common\models\User', + ), + 'log' => array( + 'targets' => array( + array( + 'class' => 'yii\log\FileTarget', + 'levels' => array('error', 'warning'), + ), + ), + ), + ), + 'params' => $params, +); diff --git a/apps/bootstrap/config/params.php b/apps/advanced/backend/config/params.php similarity index 100% rename from apps/bootstrap/config/params.php rename to apps/advanced/backend/config/params.php diff --git a/apps/advanced/backend/controllers/SiteController.php b/apps/advanced/backend/controllers/SiteController.php new file mode 100644 index 0000000000..09052d2780 --- /dev/null +++ b/apps/advanced/backend/controllers/SiteController.php @@ -0,0 +1,33 @@ +render('index'); + } + + public function actionLogin() + { + $model = new LoginForm(); + if ($model->load($_POST) && $model->login()) { + return $this->redirect(array('site/index')); + } else { + return $this->render('login', array( + 'model' => $model, + )); + } + } + + public function actionLogout() + { + Yii::$app->user->logout(); + return $this->redirect(array('site/index')); + } +} diff --git a/apps/bootstrap/runtime/.gitignore b/apps/advanced/backend/models/.gitkeep similarity index 100% rename from apps/bootstrap/runtime/.gitignore rename to apps/advanced/backend/models/.gitkeep diff --git a/apps/advanced/backend/runtime/.gitignore b/apps/advanced/backend/runtime/.gitignore new file mode 100644 index 0000000000..c96a04f008 --- /dev/null +++ b/apps/advanced/backend/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/apps/bootstrap/views/layouts/main.php b/apps/advanced/backend/views/layouts/main.php similarity index 85% rename from apps/bootstrap/views/layouts/main.php rename to apps/advanced/backend/views/layouts/main.php index 635e1181af..9f66a11adb 100644 --- a/apps/bootstrap/views/layouts/main.php +++ b/apps/advanced/backend/views/layouts/main.php @@ -1,14 +1,14 @@ registerAssetBundle('app'); +AppAsset::register($this); ?> beginPage(); ?> @@ -24,15 +24,13 @@ $this->registerAssetBundle('app');