daxter1987/laravel-env
Composer 安装命令:
composer require daxter1987/laravel-env
包简介
Environment for laravel applications with mysql
README 文档
README
By installing this composer package into your laravel application, this enables the php artisan dax:install command, which creates a docker-compose.yml and a daxenv.sh file into your laravel root directory. Then you can run docker compose up -d and you have a laravel environment with a database.
Requirements
- Must have docker installed
- Must have docker-compose installed
Installation
1. Install using composer by running:
composer require daxter1987/laravel-env
2. Once installed run the command
php artisan dax:install
This creates 2 files:
- docker-compose.yml: compose file with 2 containers
- Ubuntu image with nginx and Php 7.3
- Database image
- daxenv.sh: file with useful shortcuts to run your environment
This also checks the .gitignore in your laravel project and adds the line /db if it doesn't exist. This is the folder where docker will store your local database container volume.
3. [Optional but recommended] Give the daxenv.sh execute permissions
If you want to use the shortcuts give the daxenv.sh file executing permissions by running the command:
sudo chmod 777 daxenv.sh
4. Configure database
The database connection credentials can be found in your newly created docker-compose.yml file. Make sure the database connection is properly configured either in your .env file or your config/database.php file.
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: root
MYSQL_PASSWORD: root
Usage
With shortcuts
To start the environment run
./daxenv.sh up
To stop the environment
./daxenv.sh down
To ssh into the laravel container
./daxenv.sh ssh
Without shortcuts
To start the environment run
docker-compose up -d
To stop the environment
docker-compose down
To ssh into the laravel container run docker container ls to get the name of the container, then replace the container name for CONTAINER_NAME in the command below
docker exec -it CONTAINER_NAME ssh
xdebug and PHPStorm
Setup
The container comes with xdebug installed (if you run phpinfo() you would see the configuration). To use it, set up PHPStorm:
-
Go to Languages and Frameworks > PHP > Servers and set
- Name: Name of project
- Host: localhost
- Port: 8080
- Debugger Xdebug
- Use path mappings = true
- Set Absolute path on server /var/www/html
-
Go to "Add Configurations"
- Click +
- Select PHP remote Debug template
- Name: Name of project
- Server: previously created server
- IDE key: PHPSTORM
- Click Apply
Run
- Click on the Bug Icon
- Send a GET request with
?XDEBUG_SESSION_START=PHPSTORM
- Send a post request with XDEBUG_SESSION_START=PHPSTORM as a param
daxter1987/laravel-env 适用场景与选型建议
daxter1987/laravel-env 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.77k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 daxter1987/laravel-env 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 daxter1987/laravel-env 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 14.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-06