承接 charcoal/boilerplate 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

charcoal/boilerplate

Composer 安装命令:

composer create-project charcoal/boilerplate

包简介

A Charcoal Project Boilerplate

README 文档

README

A skeleton for creating Web sites with Charcoal.

See below for an overview of this skeleton's structure and objectives.

Installation

This skeleton is available on Packagist and can be installed using Composer:

composer create-project charcoal/boilerplate example-project

After the skeleton is installed, point the document root of your Web server to the example-project/www directory.

By default, the skeleton includes an Apache .htaccess file. See below for examples on configuring your Web server.

From the command line, PHP provides a built-in Web server for quickly serving your project:

cd www
php -S localhost:8080

Visit http://localhost:8080 in your browser to see the following:

Example: Skeleton's default index page

Screen capture of the skeleton's unstyled index page

Update

The skeleton does not provide any process for automated upgrades. You will have to port any updates manually.

This is because the skeleton is a starting point for your project and its various files are mainly present for demonstration and would otherwise be removed or modified for your purposes.

Application Configuration

Create a copy of the config/config.sample.json file and name it config/config.local.json. This is your environment specific configuration file and it should be excluded from your project's source control repository. Edit this file to configure services such as the database, third-party services, logs, and caches.

Any other options relevant to your project should be changed in all other files in the config directory.

Database Configuration

If your project does not require any database storage, use a database in-memory such as SQLite by adding the following to the config/config.local.json file:

{
    "databases": {
        "default": {
            "type": "sqlite",
            "database": ":memory:"
        }
    },
    "default_database": "default"
}

If your project uses MySQL, create an empty database and ensure a SQL user has the proper permissions for this database. Then add the following to the config/config.local.json file:

{
    "databases": {
        "default": {
            "type": "mysql",
            "hostname": "127.0.0.1",
            "database": "foobar",
            "username": "foo_bar",
            "password": "l337"
        }
    },
    "default_database": "default"
}

Project Name

By default, the skeleton uses "Acme" as a dummy name. There are a few occurrences throughout the repository that should be changed to reflect your project:

You should also change the details of the Composer dependency manifest:

Administration Dashboard

A quick-and-dirty command line script is provided to install the assets for the administration area:

./build/scripts/install-charcoal-admin.sh

Afterwards, visit http://localhost:8080/admin/login in your browser to see the following:

Example: Charcoal's administration login page

Screen capture of Charcoal's administration login page

The administration area can be customized from the config/admin.json file.

Install Locomotive Boilerplate

Optionally, another quick-and-dirty script is provided to install the Locomotive's front-end development tools:

./build/scripts/install-locomotive-boilerplate.sh

For more information, visit Locomotive's Boilerplate repository.

Server Requirements

Server Configuration

Apache Configuration

Use the following configuration as a starting point for configuring the Apache HTTP server. Note that this should be used instead of the skeleton's .htaccess file.

Note that you should replace path/to/example-project/www with the actual path for example-project/www.

Example: Apache configuration
# Set document root to be "example-project/www"
DocumentRoot "path/to/example-project/www"

<Directory "path/to/example-project/www">
    <IfModule mod_rewrite.c>
        RewriteEngine on

        # If a directory or a file does not exist,
        # forward the request to the application controller
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php
    </IfModule>
</Directory>

Nginx Configuration

Use the following configuration as a starting point for configuring the Nginx HTTP server.

Note that you should replace path/to/example-project/www with the actual path for example-project/www.

Example: Nginx configuration
server {
    listen 80;
    listen [::]:80;

    server_name example-project.test;
    root        /path/to/example-project/www;
    access_log  /path/to/example-project/logs/access.log;
    error_log   /path/to/example-project/logs/error.log;

    index index.php;

    charset utf-8;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location = /robots.txt  {
        access_log off;
        log_not_found off;
    }
 
    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~* /\. {
        deny all;
    }
}

Development

Linting

By default, the skeleton is developed with a number of coding style and static code analysis tools:

PHPStan and Psalm are used together to take advantage of each one's specialties.

Linting can be executing by running one of the following commands:

# Run JSON Lint, PHP Lint, PHPCS, PHPStan, and Psalm
composer lint

# Run only JSON Lint
composer lint:json
./vendor/bin/jsonlint config/*.json

# Run only PHP syntax check
composer lint:php
php -l src/*.php

# Run only PHPCS
composer lint:phpcs
./vendor/bin/phpcs -ps --colors src/

# Run only PHPStan
composer lint:phpstan
./vendor/bin/phpstan analyse

# Run only Psalm
composer lint:psalm
./vendor/bin/psalm

Most of these tools can be configured from the following files:

Testing

By default, PHP tests are located in the tests directory and developed with the PHPUnit framework.

Tests can be executing by running one of the following commands:

composer test
composer test:phpunit
./vendor/bin/phpunit

PHPUnit can be configured from the phpunit.xml.dist or a local phpunit.xml file.

Optimization

Locked Dependencies

Your project's dependencies can be installed considerably faster when you include the composer.lock file in your project's source control repository. Composer automatically generates and keeps this file up to date.

Autoloader Optimization

When deploying to production, ensure that you are optimizing Composer's class autoloader map so Composer can rapidly find the corresponding file for a given PHP class:

composer install --optimize-autoloader --no-dev

Contributing

We appreciate any contribution to the skeleton and Charcoal, whether it's a bug, typo, suggestions, or improvements.

Overview

Although it is ready to use, this skeleton is still incomplete.

It does not yet showcase all of the features of the Charcoal framework and therefore requires a lot of manual tinkering for options.

The following is a short "mission statement" of what is expected to be accomplished with this skeleton:

  • A fully automated setup process.
  • Support for unilingual and multilingual applications.
    • Default data provided in English and French.
    • Easy internationalization (i18n) and localization (l10n).
  • Support for Mustache and Twig templating.
    • Home page, with a few options and widgets (like carousel) or similar.
    • News list / news details, with attachment support.
    • Calendar (event list) with ajax options / event details, with attachment support.
    • Blog / article details, with attachment support and options to enable comments, and ajax actions
    • Contact, with a contact form that saves to a database and send a confirmation email depending to category options, with ajax actions.
    • Map, with locations by categories.
  • A working administration dashboard.
    • User management.
    • With a default configuration that allows to manage CMS objects (sections, news, events, blogs, locations, etc.)
    • Permission system working and enabled.
    • Notification system working and enabled.
    • Revisioning system working and enabled.
    • Media library working and enabled.
    • Built-in help (doc) system working and enabled.
  • Metadata 100% fully working on every pages and for every objects.
    • Use objects' metadata information, which all are editable in charcoal-admin.
  • Provide an optimized set of SEO features.
  • Search enabled
    • Results returned for all types of cms objects (sections, news, events, blogs, locations, etc.)
    • Used keywords, which all are editable in charcoal-admin.
    • Also search in attachments.
    • Auto-complete enabled and working.
  • 100% tested with PHPUnit.

🚂

charcoal/boilerplate 适用场景与选型建议

charcoal/boilerplate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 82 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「boilerplate」 「project」 「Skeleton」 「charcoal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 charcoal/boilerplate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 charcoal/boilerplate 我们能提供哪些服务?
定制开发 / 二次开发

基于 charcoal/boilerplate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 82
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-08