evanwarner / craft-boilerplate
A Craft CMS boilerplate build.
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Language:CSS
Type:project
pkg:composer/evanwarner/craft-boilerplate
README
This project serves as a boilerplate to generate a new Craft CMS project through composer create-project. It is an opinionated configuration made specifically for how I like to build sites with Craft.
The boilerplate creates a Craft 4.x build with a DDEV configuration for local development. If you prefer a different local development environment than DDEV, you're free to adjust the setup process accordingly.
How to use the boilerplate
To generate a new Craft CMS project with this package, run the following, where <path> is the system path you want to be the project root:
composer create-project evanwarner/craft-boilerplate <path>
Note: As part of the project creation process this file will be renamed to SETUP.md, while the file README-site.md will become README.md, as it is intended to be the README file that lives on with the generated project.
Project Setup
The following should be completed immediately after generating a new project. Once complete, this file can be deleted.
GIT
cdinto the project rootgit initgit commit --allow-empty -m "Initial commit"- Add desired git remote (assuming named
origin) git push -u origin mastergit checkout -b develop
Structure
- Rename
/webrootto an appropriate name for this project (to match the production server)- Update the
docrootconfig in/.ddev/config.yamlto match - Update the
config.webrootvariable inpackage.jsonto match - Update the
* > aliases > @webrootpath in/craft/config/general.phpto match - Update the paths in
.gitignoreto match - Update the paths in the Getting Started section in
README.mdto match
- Update the
- (Optional) You may rename
/craftto a preferred name for this project- Update the
composer_rootconfig in/.ddev/config.yamlto match - Update the
web_environment > CRAFT_CMD_ROOTconfig in/.ddev/config.yamlto match - Update the
config.craftvariable inpackage.jsonto match - Update the shared bootstrap
requirepath in/[webroot]/index.phpto match:require dirname(__DIR__) . '/[craft]/bootstrap.php';
- Update the paths in
.gitignoreto match - Update the paths in the Getting Started section in
README.mdto match - Update the paths in the File Organization section in
README.mdto match - Be aware of this change as you follow the remaining steps in this setup
- Update the
- Ensure permissions of these directories
chmod 774 /[craft]/storagechmod 774 /[craft]/vendor
- Ensure permissions on the craft cli executable
chmod 755 /[craft]/craft
Project Configuration
- Edit the Project Name and Project Description in
README.md - Edit the
nameconfig in/.ddev/config.yaml - Set the
nameanddescriptioninpackage.json - Set the
nameanddescriptionin/[craft]/composer.json - Set the
CRAFT_APP_IDin/[craft]/.env - Set the
SYSTEM_NAMEin/[craft]/.env - Set the
SITE_NAMEin/[craft]/.env - Configure the project domains
- Edit the project domain under the
additional_fqdnsconfig in/.ddev/config.yaml - Set the
SITE_URLin/[craft]/.env - Set the
start_urlin/src/manifest.jsonto the production domain
- Edit the project domain under the
- Set the
SYSTEM_EMAILin/[craft]/.env - Set the
SYSTEM_SENDER_NAMEin/[craft]/.env - Set the
SYSTEM_REPLY_TO_EMAILin/[craft]/.env - Set the
TEST_EMAILin/[craft]/.env - Comment out or delete the www and https rewrite settings in
/src/.htaccessas desired
Environment Setup
- From the project root run
npm run devto compile source files and watch for changes
DDEV
- Adjust the additional environment configs (versions, ports) in
/.ddev/config.yamlas desired - From the project root run
ddev start
Craft Setup
- Create a
CRAFT_SECURITY_KEYin/[craft]/.envddev craft setup/security-key(or generate one manually)
- Run the Craft installation at
http://[local hostname]/manage- Set the Name of the primary site to
$SITE_NAME - Set the URL of the primary site to
$SITE_URL
- Set the Name of the primary site to
- In Settings > General set the system Time Zone appropriately
- In Settings > Sites set the Name of the site group as desired
GIT Development Branch
- Delete this file.
git add -Agit commit -m "Add and configure site boilerplate"git push -u origin develop