PHPackages                             abdalex/framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. abdalex/framework

ActiveLibrary[Framework](/categories/framework)

abdalex/framework
=================

getConfig

0185PHP

Since Jun 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Alexchent/Framework)[ Packagist](https://packagist.org/packages/abdalex/framework)[ RSS](/packages/abdalex-framework/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

根据运行环境自动选择配置
============

[](#根据运行环境自动选择配置)

### 1. composer require abdalex/framework dev-master

[](#1-composer-require-abdalexframework-dev-master)

### 2. 在laravel项目中 bootstrap/app.php件中，return $app之前添加

[](#2-在laravel项目中-bootstrapappphp件中return-app之前添加)

```

define('BASE_PATH', '您的项目的根路径');

$environmentPath = $app->environmentPath();//.env所在目录
$setEnv = trim(file_get_contents($environmentPath.'/.env'));//获取.env文件内容
file_exists($environmentPath.'/.env.'.$setEnv)
    ? $app->loadEnvironmentFrom('.env.'.$setEnv)
    : exit('无效环境');

\Framework\Common::$suffix = $setEnv;//不同环境的配置文件，与laravel保持一致
\Framework\Common::$path = 'const/';//配置文件的路径

```

### 3. laravel的配置文件.env清空。根据环境不同设置不同的值

[](#3-laravel的配置文件env清空根据环境不同设置不同的值)

开发环境dev 测试环境test 生产环境production

### 4. 在项目根目录下创建const文件夹

[](#4-在项目根目录下创建const文件夹)

### 5. 在const目录下创建配置文件。如阿里配置

[](#5-在const目录下创建配置文件如阿里配置)

ali.dev.php //后缀dev表示开发环境配置

```
return [
    'db' => [
            'host'=>'127.0.0.1',
            'port'=>3306,
        ],
    'redis' =>[
            'host'=>'127.0.0.1',
            'port'=>6679,
    ]
];
```

ali.test.php //后缀test表示测试环境配置

```
return [
    'db' => [
            'host'=>'172.18.10.11',
            'port'=>3306,
        ],
    'redis' =>[
            'host'=>'172.18.10.11',
            'port'=>6679,
    ]
];
```

读取配置
----

[](#读取配置)

```
use Framework\Common;

//读取const目录下config.php返回数组中，redis的值
$aliConfig = Common::getConfig('config.redis');

//读取const目录下config.php返回数组中，redis的host信息
$aliConfig = Common::getConfig('config.redis.host');

//可以以此类推，可以读取配置文件中的任意信息
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/36b2e3d528d5e5a24dcff8b048f2acf3627ed8b427ef0464a93d34c3029d1c20?d=identicon)[alex.chen](/maintainers/alex.chen)

---

Top Contributors

[![Alexchent](https://avatars.githubusercontent.com/u/19601444?v=4)](https://github.com/Alexchent "Alexchent (11 commits)")

### Embed Badge

![Health badge](/badges/abdalex-framework/health.svg)

```
[![Health](https://phpackages.com/badges/abdalex-framework/health.svg)](https://phpackages.com/packages/abdalex-framework)
```

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
