Skip to content

Commit

Permalink
Merge branch 'develop' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
der-On authored Nov 6, 2024
2 parents d4f889e + 4ff066f commit 0faa068
Show file tree
Hide file tree
Showing 1,370 changed files with 38,430 additions and 41,095 deletions.
11 changes: 11 additions & 0 deletions .devcontainer/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
]
}
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM php:8.3-apache-bookworm

# Install PHP extensions
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN install-php-extensions @composer gd intl zip xdebug

# Enable Apache2 rewrite module
RUN a2enmod rewrite
70 changes: 70 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Welcome to the Winter development environment

<p align="center">
<img src="https://github.com/wintercms/winter/raw/develop/.github/assets/Github%20Banner.png?raw=true" alt="Winter CMS Logo" width="100%" style="max-width: 600px" />
</p>

This development environment container sets up a fully-functional installation of Winter CMS, running on Apache 2 with PHP 8.3, and makes it simple to start working with Winter CMS in VSCode, PHPStorm and online code-editing suites such as GitHub Codespaces.

If you opted to use the `bootstrap-winter` feature, which is enabled by default, Winter CMS will be automatically configured and an administrator account will be generated with the credentials **admin / admin** for you to quickly sign in. It is recommended once you have done so that you change this password immediately.

The following plugins and themes will be installed automatically with this feature:

- Workshop theme (https://github.com/wintercms/wn-workshop-theme)
- Pages plugin (https://github.com/wintercms/wn-pages-plugin)
- Blog plugin (https://github.com/wintercms/wn-blog-plugin)
- Test plugin (https://github.com/wintercms/wn-test-plugin)

## Using this environment

When this environment is built, the Apache 2 service is automatically started, with the root folder of the Winter project being used. A preview of the website will be opened immediately - if you do not see this, you can open the **Ports** tab in VSCode to view the URL generated for viewing the project.

XDebug is enabled by default, and allows you to quickly use step debugging. It will be available in the **Debug** tab of VSCode or similar screen in other IDEs.

By default, when using the `bootstrap-winter` feature, changes to certain folders and locations will be ignored by Git to keep the change list clean. This includes the `plugins` and `themes` folders, the `config/app.php` file and the `composer.json` file in the root folder. If you wish to use this environment for your own projects, it is recommended that you do not use this feature. Please see the **Using in your own projects** section below for using this environment outside of Winter development.

## Environment platform

The following software is installed in this environment.

- Apache 2.4
- PHP 8.3 with the following extensions:
- `intl`
- `gd`
- `xdebug`
- Composer
- NodeJS 22 (including `npm`)
- Git

## Using in your own projects

You may use this development environment for your own projects, making it a great starting point to hit the ground running with Winter. It is recommended that you *disable* the `bootstrap-winter` feature when using this environment for your own projects.

You may disable this feature by modifying the `.devcontainer/devcontainer.json` file before running the container and commenting out the feature:

```json5
"ghcr.io/devcontainers/features/git:1": {},
"./local-features/apache-config": "latest",
// Comment the following feature if you wish to bootstrap and configure Winter manually (ie. you wish to use this for your own project)
//"./local-features/bootstrap-winter": "latest"
},
"overrideFeatureInstallOrder": [
```

If this feature is disabled, you must bootstrap your project manually. This includes:

- Downloading the Composer dependencies.
- Generating the configuration for the project, either as an `.env` file or in the `config` folder.
- Finally, Running the database migrations.

You may view the `.devcontainer/local-features/bootstrap-winter/bootstrap.sh` file to see how we bootstrap Winter, and run these commands manually. You will only need to do this once per project container.

If you wish to mount your own volumes, use your own databases or any other complex usages, please review the [Docker documentation](https://docs.docker.com/) to set this up on the container.

## Troubleshooting

### Preview website missing styles / assets on Codespaces

By default, ports that are forwarded in Codespaces are private by default. While we have tried to fix this automatically in the Winter bootstrap process by making the port public through the GitHub CLI, it unfortunately is not consistently applied.

If you find that your preview website is missing assets or styling, open the **Ports** tab by opening the Action Palette in Codespaces (`F1`) and using the **View: Toggle Ports** action. Right click on the **Preview Winter installation** port, right click on it and choose **Port Visiblity -> Public**. This should resolve the issue.
67 changes: 67 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Winter on PHP 8.3",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"configureZshAsDefaultShell": true,
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "22"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"./local-features/apache-config": "latest",
// Comment the following feature if you wish to bootstrap and configure Winter manually (ie. you wish to use this for your own project)
"./local-features/bootstrap-winter": "latest"
},
"overrideFeatureInstallOrder": [
"ghcr.io/devcontainers/features/common-utils"
],
"containerEnv": {
"DB_CONNECTION": "sqlite",
"DB_DATABASE": "${containerWorkspaceFolder}/storage/database.sqlite"
},
"postStartCommand": "sudo rm -rf /var/www/html && sudo ln -s ${containerWorkspaceFolder} /var/www/html && service apache2 start",
"forwardPorts": [8080],
"portsAttributes": {
"8080": {
"label": "Preview Winter installation",
"onAutoForward": "openPreview"
},
"9003": {
"label": "Xdebug",
"onAutoForward": "notify"
}
},
"customizations": {
"vscode": {
"settings": {
"php.validate.executablePath": "/usr/local/bin/php",
"phpcs.executablePath": "${containerWorkspaceFolder}/vendor/bin/phpcs"
},
"extensions": [
"xdebug.php-debug",
"bmewburn.vscode-intelephense-client",
"shevaua.phpcs",
"swordev.phpstan",
"wintercms.winter-cms"
]
},
"codespaces": {
"openFiles": [
".devcontainer/README.md"
]
}
},
"remoteUser": "vscode"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"id": "apache-config",
"name": "Apache configuration changes"
}
24 changes: 24 additions & 0 deletions .devcontainer/local-features/apache-config/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

USERNAME="vscode"

set -e

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
export DEBIAN_FRONTEND=noninteractive

apt-get update && apt-get -y install --no-install-recommends lynx
usermod -aG www-data ${USERNAME}
echo "Listen 8080" > /etc/apache2/ports.conf
apt-get clean -y && rm -rf /var/lib/apt/lists/*

echo "Done!"
46 changes: 46 additions & 0 deletions .devcontainer/local-features/bootstrap-winter/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -e

echo "### Updating Composer dependencies"
php ${PWD}/.devcontainer/local-features/bootstrap-winter/update-composer.php
composer update --no-interaction --no-scripts --no-audit

if [ ! -f "${PWD}/.env" ]; then
echo "### Generating .env file"
php artisan winter:env -q
php artisan key:generate -q
fi

if [ "${DB_CONNECTION}" = "sqlite" ] && [ "${DB_DATABASE}" = "${PWD}/storage/database.sqlite" ] && [ ! -f "${PWD}/storage/database.sqlite" ]; then
SETUP_ADMIN=true
echo "### Creating SQLite database"
touch storage/database.sqlite
fi

echo "### Run migrations"
php artisan migrate

if [ "${SETUP_ADMIN}" = true ]; then
echo "### Setup admin"
php artisan winter:passwd admin admin
fi

echo "### Switch theme"
php artisan theme:use workshop

echo "### Ignoring files in Git"
echo "plugins/*" >> "${PWD}/.git/info/exclude"
echo "themes/*" >> "${PWD}/.git/info/exclude"
echo "composer.json" >> "${PWD}/.git/info/exclude"
git update-index --assume-unchanged composer.json
git restore config

cp ${PWD}/.devcontainer/.vscode/launch.json ${PWD}/.vscode/launch.json

if [ "${CODESPACES}" = "true" ]; then
echo "### Configure for Codespaces"
php ${PWD}/.devcontainer/local-features/bootstrap-winter/codespaces.php
git update-index --assume-unchanged config/app.php
gh codespace ports visibility 8080:public -c $CODESPACE_NAME
fi
25 changes: 25 additions & 0 deletions .devcontainer/local-features/bootstrap-winter/codespaces.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$root = dirname(__DIR__, 3);

require_once $root . '/vendor/autoload.php';

use Winter\LaravelConfigWriter\ArrayFile;
use Winter\LaravelConfigWriter\EnvFile;

$config = ArrayFile::open($root . '/config/app.php');

$config->set('trustedHosts', [
'localhost',
'^(.+\.)?app.github.dev',
]);
$config->set('trustedProxies', '*');

$config->write();

$env = EnvFile::open($root . '/.env');

$env->set('APP_URL', 'https://' . $_ENV['CODESPACE_NAME'] . '.app.github.dev');
$env->set('LINK_POLICY', 'force');

$env->write();
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "bootstrap-winter",
"name": "Bootstrap Winter",
"description": "Bootstrap and configure Winter CMS automatically for development on Winter itself",
"postCreateCommand": "sh ./.devcontainer/local-features/bootstrap-winter/bootstrap.sh"
}
5 changes: 5 additions & 0 deletions .devcontainer/local-features/bootstrap-winter/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

echo "Done"
22 changes: 22 additions & 0 deletions .devcontainer/local-features/bootstrap-winter/update-composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
$composerPath = dirname(__DIR__, 3) . '/composer.json';
$composer = json_decode(file_get_contents($composerPath), true);

$packages = [
'winter/wn-test-plugin' => 'dev-main',
'winter/wn-blog-plugin' => 'dev-main',
'winter/wn-blog-plugin' => 'dev-main',
'winter/wn-workshop-theme' => 'dev-main',
];

// Install Winter packages
foreach ($packages as $package => $version) {
if (!in_array($package, array_keys($composer['require']))) {
$composer['require'][$package] = $version;
}
}

file_put_contents(
$composerPath,
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EditorConfig is awesome: http://EditorConfig.org
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true
Expand All @@ -10,3 +10,6 @@ trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[**/.github/workflows/**.{yml,yaml}]
indent_size = 2
43 changes: 43 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
APP_NAME="Winter CMS"
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_LOCALE=en

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file

SESSION_DRIVER=file

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

QUEUE_CONNECTION=sync

MAIL_MAILER=log
MAIL_LOG_CHANNEL=null
MAIL_HOST=null
MAIL_PORT=null
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="${APP_NAME}"

ROUTES_CACHE=false
ASSET_CACHE=false
LINK_POLICY=detect
ENABLE_CSRF=true
DATABASE_TEMPLATES=false

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
11 changes: 10 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
* text=auto
* text=auto

*.md diff=markdown
*.php diff=php

/.devcontainer export-ignore
/.github export-ignore
.gitattributes export-ignore
CHANGELOG.md export-ignore
/package.json export-ignore
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/1_BUG_REPORT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body:
description: Please select the Winter CMS build that you encountered your issue with. You can find the version in the **Updates & Plugins** section of the Settings page of the Backend, or by running the `php artisan winter:version` command.
options:
- dev-develop
- 1.2
- 1.1
- 1.0 (please try updating first)
- Other (please specify below)
Expand Down
Binary file added .github/assets/sponsor-route4me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0faa068

Please sign in to comment.