{"id":15042179,"url":"https://github.com/2amigos/yii2-app-template","last_synced_at":"2025-10-04T05:31:31.307Z","repository":{"id":54589135,"uuid":"77640341","full_name":"2amigos/yii2-app-template","owner":"2amigos","description":"Yii 2 Basic Application Template with ConfigKit.","archived":true,"fork":false,"pushed_at":"2021-02-08T22:21:47.000Z","size":82,"stargazers_count":55,"open_issues_count":8,"forks_count":21,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-12-26T15:06:18.707Z","etag":null,"topics":["2amigos","boilerplate","php","project-template","yii2","yii2-application-template"],"latest_commit_sha":null,"homepage":"https://2amigos.us","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2amigos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-29T21:15:25.000Z","updated_at":"2024-10-22T15:43:41.000Z","dependencies_parsed_at":"2022-08-13T20:40:25.862Z","dependency_job_id":null,"html_url":"https://github.com/2amigos/yii2-app-template","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2amigos%2Fyii2-app-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2amigos%2Fyii2-app-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2amigos%2Fyii2-app-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2amigos%2Fyii2-app-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2amigos","download_url":"https://codeload.github.com/2amigos/yii2-app-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235222543,"owners_count":18955327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2amigos","boilerplate","php","project-template","yii2","yii2-application-template"],"created_at":"2024-09-24T20:46:57.791Z","updated_at":"2025-10-04T05:31:25.850Z","avatar_url":"https://github.com/2amigos.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii 2 Project Template With ConfigKit\n\n[![Packagist Version](https://img.shields.io/packagist/v/2amigos/yii2-app-template.svg?style=flat-square)](https://packagist.org/packages/2amigos/yii2-app-template)\n[![Latest Stable Version](https://poser.pugx.org/2amigos/yii2-app-template/version)](https://packagist.org/packages/2amigos/yii2-app-template)\n[![Total Downloads](https://poser.pugx.org/2amigos/yii2-app-template/downloads)](https://packagist.org/packages/2amigos/yii2-app-template)\n\nThis project is an example of what can be done with \n[https://github.com/2amigos/yii2-config-kit](https://github.com/2amigos/yii2-config-kit).\n\nIt's a proposed application project template for Yii2 projects. This new template is perfect for projects of any size. \nEven though the Yii community recommends the usage of the advanced project template, but if we look carefully at that \ntemplate you'll soon realize that what it has is simply three applications in one: `backend / frontend / console`. So, \nwhat's the difference between that template and this one? A shared common folder and another app? What stops you from doing the \nsame with this type of starting point architecture? Right, absolutely nothing.\n\nOur knowledge and experience with Yii has taught us that the advanced template is not really necessary to build anything that this \ntemplate cannot also handle. Do you wish to create a super-admin application? Then simply add another folder wherever \nyou wish and inject the shared resources from the `src` folder, the `business` or `domain` logic. \n\nIf you are using our proposed template then please take into consideration some recommendations from us:\n\n- Make sure your application logic **is not within** your models. Yes, avoid that MVC pattern recommendation to have \nthick models. You will surely end up with many God objects (monolithic models with huge amounts of code that become so hard to \nmaintain that you'll regret the day you started coding them; especially, when you have to port that business logic to a \nbetter/newer architecture).\n- Keep your controllers thin, your models thinner and your views as clean of PHP and JS code as you can. \n- If your application is going to be large, please, do not use the events of your models even though they allow you to \ndo so, make sure they are not being part of a large process. You will end up with a nightmare hard to test, hard to \nmaintain and/or scale. Try to implement the observer pattern differently, allowing your pool of observer objects to be \nnotified about those events. That will make your code easier to test.\n- Do not mix different code in your views. Please, please, do not use inline scripts and/or css do not inject javascript \ncode in your PHP files, do not use the dynamic javascript jquery onload capabilities of the framework. I believe this approach is so wrong. Use it for small projects, but do not use it for large ones. Stick with separation of concerns, and\nkeep js where it should be: at the frontend, within JS files... and do us all a favor, do not be a fashionist. Don't end \nup having your HTML templates in your javascript components, even if the library allows you to do so. K.I.S.S., my friends, K.I.S.S.\nall the way.\n- Use task managers, or module bundlers for your javascript files. We have added a `.bowerrc` and `gulpfile.js` to keep \nit as simple as possible. Yii Asset Bundlers are good and serve the purpose for small projects, but be honest, is this where\nthe Web design trends are going nowadays?\n  \nYii is a great framework, because of all the tools that it encapsulates. It has great flexibility and even though a lot \nof people complain about its inheritance madness and internal design, it is still a good robust framework. We just need to be \nvery cautious with that power, as it could bring you more problems than advantages. \n\n\n## Directory Structure\n```\napp                 [ Yii's application related code: commands, components, controllers, bundles, models, modules, \n|                     views and widgets ]\n├── assets          [ contains asset's definitions ]\n├── commands        [ contains Console commands (Yii names them controllers) ]\n├── controllers     [ contains Web controller classes ]\n├── migrations      [ database migrations ]\n├── models          [ contains model classes ]\n├── views           [ contains application views ]\n└── widgets         [ contains widget components ]\nbin                 [ contains command-line executable scripts ]\nbootstrap           [ contains bootstrap process files ]\nconfig              [ contains application configuration files ]\npublic              [ contains Web application entry script + static resources ]\nruntime             [ contains files generated during application's runtime ]\nsrc                 [ contains domain business logic files. Portable code, free of Yii's code. Build your library here. ]\ntests               [ contains codeception tests for your application ]\n```\n\n## Requirements \n\nThe minimum requirement by this project template that your Web server supports PHP 5.4.0. But we highly recommend you \nuse the latest PHP 7+. \n\n\n## Installation \n\n### Install via Composer \n\nIf you do not have Composer, you may install it by following the instructions at getcomposer.org.\n\nYou can then install this project template using the following command:\n\n```\nphp composer.phar create-project --prefer-dist --stability=dev 2amigos/yii2-app-template your-site-name\n```\n\nOnce the commands finish simply do the following: \n\n```\ncd your-site-name \ncomposer start-server \n```\n\nYou will then can access your application on `http://localhost:8080`. To stop the server, simply type on your terminal  \n`composer stop-server` and it will be stopped. You could also simply `Ctrl+C` to stop the script execution. \n\nPlease note, that the composer's commands included on this template have been tested on Linux | Mac environments, no \nWindows sorry. \n\n\n## Testing\n\nTests are located in tests directory. They are developed with Codeception PHP Testing Framework. By default there are 3 \ntest suites:\n\n- unit\n- functional\n- acceptance\n\nFirst run the test server. This command will `inject` the `index-test.php` script on your \nweb root so you will be able to run your functional and acceptance tests: \n\n```\ncomposer start-test-server \n```\n\nThen tests can be execute by running:\n \n``` \ncomposer exec codecept run\n```\n\nOr, if you have codeception installed globally simply: \n\n```\ncodecept run \n```\n\n## Clean code\n \nWe have added some development tools for you to check your work for clean code: \n\n- PHP mess detector: Takes a given PHP source code base and look for several potential problems within that source.\n- PHP code sniffer: Tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.\n- PHP code fixer: Analyzes some PHP source code and tries to fix coding standards issues. Please, modify `.php_cs` to \n  suit your needs. \n\nAnd you should use them in that order. \n\n### Using php mess detector\n\nSample with all options available:\n\n```bash \n ./vendor/bin/phpmd ./src text codesize,unusedcode,naming,design,controversial,cleancode\n```\n\n### Using code sniffer\n \n```bash \n ./vendor/bin/phpcs -s --report=source --standard=PSR2 ./\n```\n\n### Using code fixer\n\nWe have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules. \n\n```bash \n./vendor/bin/php-cs-fixer fix ./src --config .php_cs\n```\n\n[![2amigOS!](https://s.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0?s=80)](http://www.2amigos.us) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2amigos%2Fyii2-app-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2amigos%2Fyii2-app-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2amigos%2Fyii2-app-template/lists"}