Code Monkey home page Code Monkey logo

yii-project-template's Introduction

Yii Framework

Yii Framework Project Template


Yii Framework Project Template is a skeleton application best for rapidly creating projects.

The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application.

Latest Stable Version Total Downloads Build Status

DIRECTORY STRUCTURE

config/             contains application configurations
public/             contains the entry script, published assets and other publicly available files e.g. favicon.ico and robots.txt
runtime/            contains files generated during runtime
vendor/             contains dependent 3rd-party packages
.env
.env.dist
composer.json
docker-compose.yml

REQUIREMENTS

The minimum requirement by this project template that your Web server supports PHP 7.2.

INSTALLATION

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this project template using the following command:

composer create-project --prefer-dist --stability=dev yiisoft/yii-project-template myapp
cd myapp

This gives you an empty project, which you can add application templates to, see the following sections on how to add these.

Depending on your system you might need to give write permissions to ./runtime and ./public/assets

CLI application

If you want to install a console application, which is needed for running your own console commands, you can add it by requiring the yiisoft/yii-base-cli package.

composer require yiisoft/yii-base-cli

You can now run yii help to see the available commands.

API application

If you want to create an API, you can add it by requiring the yiisoft/yii-base-api package.

composer require yiisoft/yii-base-api
vendor/bin/yii serve -p 8081

You can access the API via http://localhost:8081/.

Web application

Since web-applications use client-side assets, such as CSS and Javascript, you first choose an asset distribution system

a) Asset-packagist & composer-merge-plugin (requires only PHP)

composer require "wikimedia/composer-merge-plugin"
composer config repositories.ap '{"type": "composer", "url": "https://asset-packagist.org"}'
composer config extra.merge-plugin.include "vendor/*/*/composer.assets.json"

b) Foxy (requires npm or yarn)

composer require "foxy/foxy:^1.0.0"

Now you are able to install the web-application base along with its dependencies

 composer require yiisoft/yii-base-web
 vendor/bin/yii serve

Now you should be able to access the application via http://localhost:8080/.


You can find more available application bases on GitHub.

Docker

Clone the repository and create the environment configuration file

cp .env.dist .env

To run the installation create a bash from the PHP image

docker-compose run --rm php bash

and run the composer commands above.

Start application stack

docker-compose up -d

Access in your browser via

http://docker.host:30080

CONFIGURATION

Database

Edit the file config/db.php with real data, for example:

return [
    'class' => 'Yiisoft\Db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

NOTES:

  • Yii won't create the database for you, this has to be done manually before you can access it.
  • Check and edit the other files in the config/ directory to customize your application as required.
  • Refer to the README in the tests directory for information specific to basic application tests.

TESTING

Tests are located in tests directory.

Run directly from Docker image

docker run -it -v $PWD/yii-project:/app -w /app yiisoftware/yii2-php:7.2-apache bash

yii-project-template's People

Contributors

schmunk42 avatar hiqsol avatar samdark avatar machour avatar cebe avatar silverfire avatar amaelftah avatar fantom409 avatar maximal avatar yus-ham avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.