Total Pageviews

Showing posts with label yii2. Show all posts
Showing posts with label yii2. Show all posts

Sunday, 17 November 2024

mdBlog-by-froyot

use markdown to write blog, data manage by Yii2.

Yii 2 Basic Application Template

Yii 2 Basic Application Template is a skeleton Yii 2 application best for rapidly creating small 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.

DIRECTORY STRUCTURE

  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources

REQUIREMENTS

The minimum requirement by this application template that your Web server supports PHP 5.4.0.

INSTALLATION

Install from an Archive File

Extract the archive file downloaded from yiiframework.com to a directory named basic that is directly under the Web root.

You can then access the application through the following URL:

http://localhost/basic/web/

Install via Composer

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

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

php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic

Now you should be able to access the application through the following URL, assuming basic is the directory directly under the Web root.

http://localhost/basic/web/

CONFIGURATION

Database

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

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

NOTE: Yii won't create the database for you, this has to be done manually before you can access it.

Also check and edit the other files in the config/ directory to customize your application.

from https://github.com/froyot/mdBlog

Saturday, 20 June 2020

FeehiCMS

Feehi CMS based on yii2.

(English) 

基于yii2的CMS系统,运行环境与yii2(php>=5.4)一致。FeehiCMS旨在为yii2爱好者提供一个基础功能稳定完善的cms系统,使开发者更专注于业务功能开发。 FeehiCMS没有对yii2做任何的修改、封装,但是把yii2的一些优秀特性几乎都用在了FeehiCMS上,虽提供文档, 但FeehiCMS提倡简洁、快速上手,基于FeehiCMS开发可以无需文档,反倒FeehiCMS为yii2文档提供了最好的实例.

开发文档http://doc.feehi.com

功能

  • 多语言
  • 单元测试
  • 功能测试
  • 验收测试
  • RBAC权限管理
  • restful api
  • 文章管理
  • 操作日志
  • 适配手机
FeehiCMS提供完备的web系统基础通用功能,包括前后台菜单管理,文章标签,广告,banner,缓存,网站设置,seo设置,邮件设置,分类管理,单页...

快速体验

  1. 使用演示站点 演示站点后台 用户名:feehicms 密码123456
  2. 使用Docker容器
    $ docker pull registry.cn-hangzhou.aliyuncs.com/liufee/cms
    $ docker run --name feehicms -h feehicms -itd -p 80:80 liufee/cms

安装

前置条件: 如未特别说明,本文档已默认您把php命令加入了环境变量,如果您未把php加入环境变量,请把以下命令中的php替换成/path/to/php
  1. 使用归档文件(简单,适合没有yii2经验者)
    使用此方式安装,后台超管用户名和密码会在安装过程中让您填入
    1. 下载FeehiCMS源码 点击此处下载最新版
    2. 解压到目录
    3. 配置web服务器(参见下面)
    4. 浏览器打开 http://localhost/install.php 按照提示完成安装(若使用php内置web服务a器则地址为 http://localhost:8080/install.php )
    5. 完成
  2. 使用composer (推荐使用此方式安装)
    使用此方式安装,默认的后台超级管理员用户名admin密码123456
    composer的安装以及国内镜像设置请点击 此处
    以下命令默认您已全局安装composer,如果您是局部安装的composer:请使用php /path/to/composer.phar来替换以下命令中的composer
    1. 使用composer下创建FeehiCMS项目
          $ composer create-project feehi/cms webApp //此命令创建的FeehiCMS项目不能平滑升级新版本(目录结构简单,目前主力维护版本)
    2. 依次执行以下命令初始化yii2框架以及导入数据库
      $ cd webApp
      $ php ./init --env=Development #初始化yii2框架,线上环境请使用--env=Production
      $ php ./yii migrate/up --interactive=0 #导入FeehiCMS sql数据库,执行此步骤之前请先到common/config/main-local.php修改成正确的数据库配置
    3. 配置web服务器(参加下面)
    4. 完成
附:web服务器配置(注意是设置"path/to/frontend/web为根目录)
  • php内置web服务器(仅可用于开发环境,当您的环境中没有web服务器时)
 cd /path/to/cms
 php ./yii serve  
 
 #至此启动成功,可以通过localhost:8080/和localhost:8080/admin来访问了,在线安装即访问localhost:8080/install.php
  • Apache
 DocumentRoot "path/to/frontend/web"
 <Directory "path/to/frontend/web">
     # 开启 mod_rewrite 用于美化 URL 功能的支持(译注:对应 pretty URL 选项)
     RewriteEngine on
     # 如果请求的是真实存在的文件或目录,直接访问
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     # 如果请求的不是真实文件或目录,分发请求至 index.php
     RewriteRule . index.php
 
     # ...其它设置...
 </Directory>
  • Nginx
server {
    server_name  localhost;
    root   /path/to/frontend/web;
    index  index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
    
    location ~ /admin/(?!index.php|index-test.php|static|assets).*$ {
       rewrite /admin/(.*) /admin/index.php?r=$1 last;
    }
    
    location ~ /api/(?!index.php|index-test.php|static|assets).*$ {
       rewrite /api/(.*) /api/index.php?r=$1 last;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

运行测试

  1. 仅运行单元测试,功能测试(不需要配置web服务器)
   cd /path/to/webApp
   vendor/bin/codecept run
  1. 运行单元测试,功能测试,验收测试(需要配置完web服务器)
    1. 分别拷贝backend,frontend,api三个目录下的tests/acceptance.suite.yml.example到各自目录,并均重名为acceptance.suite.yml,且均修改里面的url为各自的访问url地址
    2. 与上(仅运行单元测试,功能测试)命令一致

项目展示

特别鸣谢

twitf 在后台时间搜索范围提供的建议和代码片段