atlas/symfony 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

atlas/symfony

Composer 安装命令:

composer require atlas/symfony

包简介

Symfony 4 bundle for Atlas 3

README 文档

README

This package makes the Atlas ORM and command-line tooling available as a bundle for Symfony 4 projects.

(Atlas is a data mapper for your persistence layer, not your domain layer.)

Installation and Configuration

  1. In your Symfony 4 project, enable contributor recipes:

    composer config extra.symfony.allow-contrib true
    
  2. Require the atlas/symfony package; this will activate a Symfony Flex recipe as part of the installation:

    composer require atlas/symfony ~1.0
    
  3. Edit these new .env variables to define your database connection:

    ATLAS_PDO_DSN=mysql:host=myhost;dbname=mydatabase
    ATLAS_PDO_USERNAME=myusername
    ATLAS_PDO_PASSWORD=mypassword
    

Note:

If you are using PHPStorm, you may wish to copy the IDE meta file to your project to get full autocompletion on Atlas classes:

cp ./vendor/atlas/orm/resources/phpstorm.meta.php ./.phpstorm.meta.php

In the atlas.yaml config file, these settings are notable:

  • atlas.orm.atlas.log_queries: set this to true to enable the web profiler data collector for query logging.

  • atlas.orm.atlas.transaction_class: set this to one of the Atlas transaction strategy classes, such as Atlas\\Orm\\Transaction\\AutoTransact. For more information, see the transactions documentation.

  • The options section under any connection configuration can be used to set PDO attributes through the PDO constructor. For example:

    dsn: '%env(resolve:ATLAS_PDO_DSN)%'
    username: '%env(resolve:ATLAS_PDO_USERNAME)%'
    password: '%env(resolve:ATLAS_PDO_PASSWORD)%'
    options:
        !php/const PDO::EMULATE_PREPARES: false
        !php/const PDO::ATTR_CASE: !php/const PDO::CASE_NATURAL

Getting Started

Generating Mappers

Use the command-line tooling to create the skeleton files for all your database tables:

mkdir src/DataSource
php bin/console atlas:skeleton

The config/packages/atlas.yaml file specifies App\DataSource\ as the namespace, and src/DataSource/ as the directory. To change them, modify the atlas.cli.config.input values for directory and namespace as you see fit.

The database table names will be converted to singular for their relevant type names in PHP. If you want a different type names for certain tables, modify the atlas.cli.transform values in the atlas.yaml file to map a from table name to a type name.

As you make changes to the database, re-run the skeleton generator, and the relevant table files will be regenerated.

For more information, see http://atlasphp.io/cassini/skeleton/.

Using Atlas

Now that there are mappers for all the database tables, you can use the Symfony dependency injection system to autowire Atlas into your classes for you.

namespace App;

use Atlas\Orm\Atlas;
use App\DataSource\Thread\Thread
use App\DataSource\Thread\ThreadRecord;

class ApplicationService
{
    public function __construct(Atlas $atlas)
    {
        $this->atlas = $atlas;
    }

    public function fetchThreadById($thread_id) : ThreadRecord
    {
        return $this->atlas->fetchRecord(Thread::class, $thread_id);
    }
}

Full documentation for using Atlas is at http://atlasphp.io/cassini/orm/:

Enjoy!

atlas/symfony 适用场景与选型建议

atlas/symfony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.86k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 07 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 18.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-26