abetter / wordpress
更佳的Laravel + Wordpress集成,用于构建非常快的Web应用。
Requires
- abetter/toolkit: ^1.6.18
- intervention/image: ^2.5
- vlucas/phpdotenv: ^3.6
- dev-master
- 1.6.26
- 1.6.25
- 1.6.24
- 1.6.23
- 1.6.22
- 1.6.21
- 1.6.20
- 1.6.19
- 1.6.18
- 1.6.17
- 1.6.16
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.27
- 1.5.26
- 1.5.25
- 1.5.24
- 1.5.23
- 1.5.22
- 1.5.21
- 1.5.20
- 1.5.19
- 1.5.18
- 1.5.17
- 1.5.16
- 1.5.15
- 1.5.14
- 1.5.13
- 1.5.12
- 1.5.11
- 1.5.10
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.999
- 1.4.998
- 1.4.997
- 1.4.996
- 1.4.995
- 1.4.994
- 1.4.993
- 1.4.992
- 1.4.991
- 1.4.99
- 1.4.98
- 1.4.97
- 1.4.96
- 1.4.95
- 1.4.94
- 1.4.93
- 1.4.92
- 1.4.91
- 1.4.9
- 1.4.1
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.71
- 1.2.70
- 1.2.69
- 1.2.68
- 1.2.67
- 1.2.66
- 1.2.65
- 1.2.64
- 1.2.63
- 1.2.62
- 1.2.61
- 1.2.60
- 1.2.59
- 1.2.58
- 1.2.57
- 1.2.56
- 1.2.55
- 1.2.54
- 1.2.53
- 1.2.52
- 1.2.51
- 1.2.50
- 1.2.49
- 1.2.48
- 1.2.47
- 1.2.46
- 1.2.45
- 1.2.44
- 1.2.43
- 1.2.42
- 1.2.41
- 1.2.40
- 1.2.39
- 1.2.38
- 1.2.37
- 1.2.36
- 1.2.35
- 1.2.34
- 1.2.33
- 1.2.32
- 1.2.31
- 1.2.30
- 1.2.29
- 1.2.28
- 1.2.27
- 1.2.26
- 1.2.25
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/plugins/wpml-translation-management/libraries/CodeMirror/minimist-1.2.8
- dev-dependabot/npm_and_yarn/plugins/wpml-translation-management/libraries/CodeMirror/qs-6.5.3
This package is auto-updated.
Last update: 2024-09-04 06:13:09 UTC
README
ABetter Wordpress是一个一键式解决方案,可以在Laravel之上使用Wordpress来构建非常快的Web应用,同时仍然使用世界上使用最广泛的CMS来管理内容和翻译。
我们快速Web应用的原理是关注点分离(SoC)和可扩展的静态缓存。我们让Wordpress处理内容后端,而Laravel处理独立的客户端。动态内容相关的API和Web服务也通过Laravel路由。
使用ABetter Toolkit,我们为Laravel/Blade提供了一些新的强大指令,帮助我们尽可能地在独立和可重用组件中分离内容——灵感来自ReactJS/VueJS。
要求
- PHP 7.2+
- Imagick 3+
- MySQL 5.7+
- Composer 1.6+
- Laravel 5.8+
- Deployer 6+
- Node 10.0+
- NPM 6.4+
安装
通过Composer
composer create-project --prefer-dist laravel/laravel . "6.*" composer require abetter/wordpress
Laravel修改
将安装/更新脚本添加到composer.json中
"scripts": { "post-install-cmd": [ "ABetter\\Wordpress\\ComposerScripts::postInstall" ], "post-update-cmd": [ "ABetter\\Wordpress\\ComposerScripts::postUpdate" ] }
注意:该脚本将修改使用全局__()方法进行字符串翻译的任何核心文件,并添加跨框架的解决方案。遗憾的是,Wordpress核心在定义全局__()之前没有检查function_exists,这会破坏未修改的Laravel + Wordpress兼容性。
向app/Http/Kernel.php中添加中间件
protected $middleware = [ \ABetter\Toolkit\SandboxMiddleware::class, \ABetter\Wordpress\Middleware::class, ];
注意:中间件有助于Blade在开发许多嵌套组件时清除视图缓存。
准备工作
- 使用.loc设置本地主机域名(例如 www.abetter.loc)
- 将主机指向/public
- 创建本地MySQL数据库
设置Laravel
编辑.env设置
APP_NAME=<name> APP_VERSION=<version> APP_KEY=base64:insert/base64/encoded/aes256/encryption/key= APP_ENV=<sandbox|local|dev|stage|production> APP_DEBUG=<true|false> APP_URL=<url> APP_PROXY=<browsersync-proxy-url> DB_DATABASE=<database> DB_USERNAME=<username> DB_PASSWORD=<password> WP_THEME=<optional-views-subfolder> WP_AUTOLOGIN=<optional-autologin-user> WP_REQUIRELOGIN=<optional-require-login-to-view>
注意:在配合Browsersync开发时,请使用APP_ENV=sandbox。
将路由添加到/routes/web.php中
// ABetter Toolkit services Route::any('image/{style?}/{path}', '\ABetterToolkitController@handle')->where('path','.*'); Route::any('proxy/{path}', '\ABetterToolkitController@handle')->where('path','.*'); Route::any('browsersync/{event?}/{path}', '\ABetterToolkitController@handle')->where('path','.*'); Route::any('service/{path?}.{type}', '\ABetterToolkitController@handle')->where(['path'=>'.*','type'=>'json']); // ABetter Wordpress main route Route::any('{path}', '\ABetterWordpressController@handle')->where('path','^(?!nova-api|nova-vendor|nova|api).*$');
注意:删除根或wp路径的任何其他路由(例如默认欢迎页面)。
将Deployer文件复制到根目录并运行一次设置
cp vendor/abetter/toolkit/deploy/deploy.php deploy.php
dep setuponce local
如有需要,运行审核修复
npm audit fix
注意:仅在全新项目上运行设置一次,因为它将替换/resources和/public中的文件。
测试构建应用
dep build local
设置Wordpress
在浏览器中访问主机(例如 http://www.abetter.loc)并按照安装说明操作。
转到/Appearance/Themes并激活ABetter主题。
转到/Plugins并激活
- 高级自定义字段。
- 禁用Gutenberg(完整支持即将推出...)。
- ... 任何您需要的其他支持的插件。
添加默认页面
<name> : <slug> : <template> : <order> Start : start : default : -1 News : news : default : 200 Privacy Policy : privacy-policy : default : 200 Search : search : search : 400 403 Forbidden : 403-forbidden : error : 403 404 Not found : 404-not-found : error : 404
转到/Settings/Reading
- 选择将主页设置为起始页
- 选择新闻作为文章页面
最后,在浏览器中访问主机
恭喜您的网站上线!
用法
开发
使用npm启动webpack和Browsersync
npm run watch
... 或者如果使用php artisan serve
php artisan serve & npm run watch
注意:使用"php artisan serve"时,您需要修改.env中的APP_PROXY为http://127.0.0.1:8000。
组件文件结构
.
├── public # Handled by build script (will be overwritten)
├── routes # Add any development routes to /web.php
├── resources #
│ ├── scripts # Global scripts in "app.js"
│ ├── styles # Global styles in "app.scss"
│ ├── fonts # Fonts here (will copy to /public on build)
│ ├── images # Images here (will copy to /public on build)
│ ├── videos # Videos here (will copy to /public on build)
│ ├── views #
│ │ ├── <theme> # Subfolder defined in .env / WP_THEME
│ │ │ ├── template.blade.php # Template file requested in route
│ │ │ │ ├── components #
│ │ │ │ │ ├── menu # Component subfolder:
│ │ │ │ │ │ ├── menu.blade.php # Template file : @component('components.menu',TRUE)
│ │ │ │ │ │ ├── menu.scss # Sass file : @style('menu.scss')
│ │ │ │ │ │ ├── menu.js # Javascript file : @script('menu.js')
...
/vendor/abetter/wordpress/ # Default components will be used if not overridden!
├── views # (e.g. html head start/end is rendered from here)
│ ├── default #
│ │ ├── robots.blade.php # Default Robots.txt template
│ │ ├── sitemap.blade.php # Default Sitemap.xml template
│ │ ├── components #
│ │ │ │ ├── html # Default HTML head components
│ │ │ │ ├── missing # Default debugging for missing components
│ │ │ │ ├── robots # Default Robots.txt component
│ │ │ │ ├── sitemap # Default Sitemap.xml component
...
注意:如果blade文件与文件夹具有相同的basename,组件名称将自动解析。
注意:组件中链接的JS/Sass文件在开发中将是外部文件以支持Browsersync实时同步,但在Stage/生产环境中将嵌入到HTML源中,以实现更好的缓存。
注意:您可以使用第二个参数为TRUE来自动结束一个@component,以避免编写@endcomponent,例如在不使用任何插槽或嵌套内容时。
部署
(即将推出)
贡献者
Johan Sjöland johan@sjoland.com
高级产品开发人员:ABetter Story Sweden AB。
许可证
MIT许可证。请参阅许可证文件以获取更多信息。