diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f14a0d5 --- /dev/null +++ b/.gitignore @@ -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? diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..9d077ef --- /dev/null +++ b/.htaccess @@ -0,0 +1,36 @@ + + 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] + + +FallbackResource /index.php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4fb9ada --- /dev/null +++ b/Dockerfile @@ -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/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..233d8d7 --- /dev/null +++ b/README.md @@ -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! diff --git a/config.php b/config.php new file mode 100644 index 0000000..ba26c0b --- /dev/null +++ b/config.php @@ -0,0 +1,180 @@ + '/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' => [ + ], +]; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0f9e0bf --- /dev/null +++ b/docker-compose.yml @@ -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: diff --git a/extensions/.gitkeep b/extensions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/index.php b/index.php new file mode 100644 index 0000000..b5955e9 --- /dev/null +++ b/index.php @@ -0,0 +1,16 @@ +handleRequest(); diff --git a/themes/.gitkeep b/themes/.gitkeep new file mode 100644 index 0000000..e69de29