initial commit

This commit is contained in:
Paul Spenke
2023-06-09 10:30:58 +08:00
parent de7a2fa28e
commit bb2b480ba2
9 changed files with 336 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist-ssr
*.local
cache
uploads
docker
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+36
View File
@@ -0,0 +1,36 @@
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect non-www. to www. (except when on a subdomain)
# RewriteCond %{HTTP_HOST} !^www\.
# RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
# RewriteRule ^ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Redirect HTTP to HTTPS
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Remove any trailing slashes from non-directories using a redirect
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_URI} (.+)/$
# RewriteRule ^ %1 [R=301,L]
# Rewrite /themes/{theme}/{file} to /themes/{theme}/public/{file}
RewriteRule ^themes/([^/]+)/(?!public/)(.*)$ themes/$1/public/$2 [L]
# Rewrite non-directory and non-file URLs to index.php
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ index.php [L]
# Allow direct access to theme files with URL format: /themes/{theme}/public/{file}
RewriteRule ^themes/([^/]+)/public/(.*)$ themes/$1/public/$2 [L]
# Allow direct access to uploaded files with URL format: /uploads/{filepath;,}
RewriteRule ^uploads/(.*)$ uploads/$1 [L]
# Rewrite all remaining requests to index.php
# RewriteRule ^ index.php [L]
</IfModule>
FallbackResource /index.php
+10
View File
@@ -0,0 +1,10 @@
FROM php:8.2-apache-bullseye
WORKDIR "/var/www/html"
RUN apt-get update; \
docker-php-ext-install pdo pdo_mysql; \
apt-get -y --no-install-recommends install \
git \
php8.2-mysql; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
+34
View File
@@ -0,0 +1,34 @@
# PHPagebuilder boilerplate
> Boilerplate for quickly spinning up websites using [PHPagebuilder](https://github.com/HansSchouten/PHPagebuilder).
This boilerplate defines the project structure for quickly creating a website that can be managed with a drag and drop pagebuilder.
## Installation
To setup your website download the boilerplate and upload it to the webroot directory of your website.
### Install PHPagebuilder with Composer
To install PHPagebuilder via composer, SSH to your webroot directory and run the following command:
```
composer require hansschouten/phpagebuilder
```
Now uncomment line 7 of `index.php`.
### Install PHPagebuilder without Composer
If you don't want to use composer, simply download the latest version of PHPagebuilder [here](https://github.com/HansSchouten/PHPagebuilder) and upload it in a directory called `phpagebuilder` inside your webroot directory.
Now uncomment lines 10 and 11 of `index.php`.
### Add the config file
Copy the `config.example.php` from your version of the [PHPagebuilder project](https://github.com/HansSchouten/PHPagebuilder) and add it as `config.php` to your website's root directory.
### Configure a database
If you use PHPagebuilder without any customizations, it requires a database for storing your pages. Just create a database and run the queries from `config/create-tables.sql` of your version of the [PHPagebuilder project](https://github.com/HansSchouten/PHPagebuilder). Next, add the database credentials to your config file.
### Login
Now you should be able to log in to the admin panel by going to the `/admin` URL of your website using `admin` and `changethispassword` (you can change these in the config file). If you are able to login you can follow the instructions to start building your website as described in the [main project's repository](https://github.com/HansSchouten/PHPagebuilder).
Note: make sure to disable error reporting in `index.php` once your website goes into production!
+180
View File
@@ -0,0 +1,180 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| General settings
|--------------------------------------------------------------------------
|
| General settings for configuring the PageBuilder.
| If you install phpb with Composer, general.assets_url line must be:
| 'assets_url' => '/vendor/hansschouten/phpagebuilder/dist',
|
*/
'general' => [
'base_url' => 'http://localhost:63000',
'language' => 'de',
'assets_url' => '/phpagebuilder/dist',
'uploads_url' => '/uploads'
],
/*
|--------------------------------------------------------------------------
| Storage settings
|--------------------------------------------------------------------------
|
| Database and file storage settings.
|
*/
'storage' => [
'use_database' => true,
'database' => [
'driver' => 'mysql',
'host' => 'mysql',
'database' => 'phpagebuilder',
'username' => 'phpagebuilder',
'password' => 'phpagebuilder',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
'uploads_folder' => __DIR__ . '/uploads'
],
/*
|--------------------------------------------------------------------------
| Auth settings
|--------------------------------------------------------------------------
|
| By default an authentication class is provided which checks for the
| credentials configured in this setting block.
|
*/
'auth' => [
'use_login' => true,
'class' => PHPageBuilder\Modules\Auth\Auth::class,
'url' => '/admin/auth',
'username' => 'admin',
'password' => 'admin'
],
/*
|--------------------------------------------------------------------------
| WebsiteManager settings
|--------------------------------------------------------------------------
|
| By default a basic WebsiteManager is provided for creating/editing pages.
|
*/
'website_manager' => [
'use_website_manager' => true,
'class' => PHPageBuilder\Modules\WebsiteManager\WebsiteManager::class,
'url' => '/admin'
],
/*
|--------------------------------------------------------------------------
| Website settings
|--------------------------------------------------------------------------
|
| By default a setting class is provided for accessing website settings.
|
*/
'setting' => [
'class' => PHPageBuilder\Setting::class
],
/*
|--------------------------------------------------------------------------
| PageBuilder settings
|--------------------------------------------------------------------------
|
| By default a PageBuilder is provided based on GrapesJS.
|
*/
'pagebuilder' => [
'class' => PHPageBuilder\Modules\GrapesJS\PageBuilder::class,
'url' => '/admin/pagebuilder',
'actions' => [
'back' => '/admin'
]
],
/*
|--------------------------------------------------------------------------
| Page settings
|--------------------------------------------------------------------------
|
| By default a Page class is provided with knowledge about its layout and URL.
|
*/
'page' => [
'class' => PHPageBuilder\Page::class,
'table' => 'pages',
'translation' => [
'class' => PHPageBuilder\PageTranslation::class,
'table' => 'page_translations',
'foreign_key' => 'page_id',
]
],
/*
|--------------------------------------------------------------------------
| Cache settings
|--------------------------------------------------------------------------
|
| Faster load time by skipping block parsing if the page has been requested before.
| A page will be cached, except if it contains a block with caching set to false.
| This can be used to prevent caching pages with content that varies per page load.
| The cached html is removed if the page is saved again in the page builder.
|
*/
'cache' => [
'enabled' => false,
'folder' => __DIR__ . '/cache',
'class' => PHPageBuilder\Cache::class
],
/*
|--------------------------------------------------------------------------
| Theme settings
|--------------------------------------------------------------------------
|
| PageBuilder requires a themes folder in which for each theme the individual
| theme blocks are defined. A theme block is a sub folder in the themes folder
| containing a view, model (optional) and controller (optional).
|
*/
'theme' => [
'class' => PHPageBuilder\Theme::class,
'folder' => __DIR__ . '/themes',
'folder_url' => '/themes',
'active_theme' => 'phpb-demo-template'
],
/*
|--------------------------------------------------------------------------
| Routing settings
|--------------------------------------------------------------------------
|
| Settings for resolving pages based on the current URI.
|
*/
'router' => [
'class' => PHPageBuilder\Modules\Router\DatabasePageRouter::class
],
/*
|--------------------------------------------------------------------------
| Class replacements
|--------------------------------------------------------------------------
|
| Allows mapping a class namespace to an alternative namespace,
| useful for replacing implementations of specific pagebuilder classes.
| Example: PHPageBuilder\UploadedFile::class => Alternative\UploadedFile::class
| Important: when overriding a class always extend the original class.
|
*/
'class_replacements' => [
],
];
+32
View File
@@ -0,0 +1,32 @@
services:
web:
build: .
restart: 'always'
volumes:
- '.:/var/www/html'
depends_on:
- mysql
ports:
- '63000:80'
links:
- mysql
networks:
- backend
mysql:
image: "mysql:8.0"
restart: 'always'
volumes:
- '.:/application'
- './docker/db:/var/lib/mysql:cached'
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=phpagebuilder
- MYSQL_USER=phpagebuilder
- MYSQL_PASSWORD=phpagebuilder
ports:
- '63002:3306'
networks:
- backend
networks:
backend:
View File
+16
View File
@@ -0,0 +1,16 @@
<?php
// Uncomment to disable error reporting
ini_set('display_errors', 1);
error_reporting(E_ERROR);
// Uncomment when using composer
//require_once __DIR__ . '/vendor/autoload.php';
// Uncomment if you downloaded PHPagebuilder
require_once __DIR__ . '/phpagebuilder/src/Core/helpers.php';
spl_autoload_register('phpb_autoload');
$config = require __DIR__ . '/config.php';
$builder = new PHPageBuilder\PHPageBuilder($config);
$builder->handleRequest();
View File