mac php

### Mac大件Apache环境,修改配置;仔细按照上面1,2两个链接教程来
User hbb
Group staff
​
### 配置虚拟主机 code /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
<VirtualHost *:8080>
    DocumentRoot "/Users/hbb/Code/phpcode/waimaoq"
    ServerName waimaoq.test
    <Directory "/Users/hbb/Code/phpcode/waimaoq">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
​
sudo killall -HUP mDNSResponder # dns
------ brew
brew list # 查看安装列表
brew services list # 检查是否成功启动
------ apache
# 如果您已经运行了内置的 Apache,则需要先将其关闭,并删除所有自动加载脚本
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
​
brew install httpd
brew services stop httpd
brew services start httpd
brew services restart httpd
​
ps -aef | grep httpd
code /opt/homebrew/etc/httpd/httpd.conf
code /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
code /opt/homebrew/etc/php/7.3/php.ini
code /opt/homebrew/etc/php/7.3/conf.d/ext-xdebug.ini
​
------ nginx
brew install nginx
brew services start nginx
brew services stop nginx
​
# php 版本,版本被弃用?https://github.com/shivammathur/homebrew-php
brew tap shivammathur/php
brew install shivammathur/php/php@7.3
brew unlink php && brew link --overwrite --force php@7.3
code /opt/homebrew/etc/php/7.3/php.ini
    
# mariadb
brew services start mariadb
brew services stop mariadb  # password hbbhbb
​
​
# brew 命令
brew services start elasticsearch
brew services stop elasticsearch
brew info elasticsearch

内置服务器 composer包

php -S localhost:8000 # 内置服务器
php --ini  # 找到 php.ini 的绝对路径
php --ri swoole  # Swoole 的扩展信息
brew unlink php@7.4
brew link php@7.3
​

xdebug

成为高级 PHP 程序员的第一步——调试(xdebug 原理篇) 成为高级 PHP 程序员的第一步——调试(xdebug 配置篇)

文件工具:

excel

file_put_contents(__DIR__.'/debug.log', $message, FILE_APPEND);   # 追加日志

封装收集

PHP 发送 HTTP 请求的几种方式

laravel

php artisan serve #本地开发环境
composer create-project --prefer-dist laravel/laravel blog "5.5.*" # 安装laravel(指定版本)

laradock

# 部署开发环境前修改.env文件,来定义开发环境
COMPOSE_PROJECT_NAME=项目名
WORKSPACE_INSTALL_XDEBUG=true
PHP_FPM_INSTALL_XDEBUG=true
MYSQL_VERSION=5.6 # 指定mysql版本
​
docker-compose up -d nginx mysql phpmyadmin

docker构建PHP开发环境 laradock phpenv

laradock

提高MacOS的速度

docker-machine env dinghy # Docker Client to the Docker Engine running on this virtual machine
​

负载均衡工具

Dnsmasq

Valet nginx haproxy

Valet 提供了一个极快的、资源消耗最少本地开发环境,非常适合只需要 PHP/MySQL 并且不需要虚拟开发环境的开发人员。

valet tld app #Valet 会自动将站点顶级域名改为 *.app

ORM

doctrine tools

ORM:doctrine

注释参考 PHP-mapping basic-mapping 常用工具

php vendor/bin/doctrine orm:generate-entities --help  #命令行
php vendor/bin/doctrine orm:generate-entities
php vendor/bin/doctrine orm:schema-tool:update --force

swoole

使用systemd管理swoole服务

swoole服务器如何做到无人值守100%可用