Giter Club home page Giter Club logo

jekuer / php-microsite-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
191.0 5.0 36.0 1.42 MB

An extremely simple and lightweight PHP framework/boilerplate to spin-up microsites at high speed. Optimized for Performance, Security, SEO, TailwindCSS, and Directus CMS.

Home Page: https://phpmicrosite.jenskuerschner.de/

License: GNU General Public License v3.0

PHP 72.81% CSS 4.88% JavaScript 21.35% Shell 0.50% Hack 0.46%
php php-framework css html5 boilerplate pwa microsite template php-microsite html5-boilerplate directus microsites gettext cms-frontend tailwindcss

php-microsite-boilerplate's Introduction

PHP Microsite Boilerplate

pagespeed-100 pwa-valid w3c-css-valid LICENSE github-stars-image

PHP Microsite Boilerplate is a PHP framework to create simple, yet strongly functional, fast, and secure websites on basically every environment.

Most frameworks and even boilerplates require an exhausting setup process, where you need to install multiple dependencies. This leads to a huge overhead of code, which you often do not need. All of those complexity is also a potential risk for your website. Furthermore, it is often not possible to use most solutions, if you need to deploy it on the cheapest shared hosting plan.

This project wants to provide you with a framework and template for this exact case:

  • You need to build a rather small website, with some functionality.
  • You choose PHP, because you want to do server-side scripting, while PHP is also maybe the only language, that runs on basically all hosting options.
  • You build this thing on your own or with a maximum of 1 other person, which makes best practice, but complex code structure more of an unnecessary overhead than a helpful concept.
  • You need to get it done fast, while you do not want to make compromises regarding security or performance.
  • You therefore do not care about clean code a lot ;).

Demo: https://phpmicrosite.jenskuerschner.de/

Key Features

  • Easy routing.
  • Progressive Web App (PWA) prepared.
  • Multilanguage prepared.
  • Directus CMS integration (incl. local cache).
  • Docker compose for local development.
  • TailwindCSS included (optional).
  • GDPR and CCPA ready.
  • Intelligent serviceworker cache.
  • Gettext support for easy translation (+ fallback if not installed on the server).
  • SEO optimized.
  • Automated sitemap generation.
  • Optimized for Social sharing.
  • Speed- & GDPR-optimized YouTube-Integration.
  • Optional CSS and JavaScript optimization with prepared build scripts.
  • Extensive in-code documentation.
  • Security Headers (.htaccess or via PHP)
  • Multiple security features (most of them require an Apache server!)
  • Prepared to run git deployment.
  • Developed to make it extremely easy for you to remove features or add your own things.

Usage

  1. Download the respective branch/tag and upload it to your website's folder - or clone the repo as you like.

  2. Adjust it to your project:

  • Check the .htaccess file, if you run it on Apache. Mind the security headers and places, where a domain/path is specified (look for YOURDOMAIN.com).
  • If you do not run it on Apache, check the index.php for the security headers setup and make sure every request (except for files) is send to the index.php. Check the nginx_deployment.sh - it is a pre-configured bash script to setup your nginx webserver.
  • Adjust the values within config.php and also mind files, which are mentioned in the comments there. Setup a connection to your Directus CMS if used.
  • Check /templates/general_meta.php and create the respective favicons.
  • Define your pages at the routing.php. (Mind legal notice and privacy policy to stay GDPR compliant!)
  • Create those pages (as specified before) as single php files within /pages.
  • Create respective files within /controller if necessary in your case.
  • Check the option to auto-redirect within multi-language at index.php and base.js.
  • Build the website with those pages, the style.css, and the base.js. Mind to minimize those files or adjust the way they get included at /templates/header.php and /templates/footer.php. If you use the prepared build script, you do not need to worry about this part.
  • Adjust the footer at /templates/footer.php to your needs.
  • Find more details in the in-code documentation - it's a well documented playground!
  1. That is basically it regarding adjustments. You can find a more detailed sample setup guide at the corresponding Medium blog post here.

  2. Building the project, hardly depends on your configuration! If you are using the TailwindCSS integration, you need to use the included build script, which requires NodeJS! If you are going plain, you can skip on that. However, not using the build scripts would also not merge and minify the css and js files. Therefore, if possible for you, it is hardly recommended. For building:

  • make sure you are within the project's root directory with your terminal.
  • run npm install.
  • run npm run build to let the magic happen.
  • That's it. Feel free to do this manually on your local machine and upload it to your host - or use some build pipelines at whatever tool you are using.

BTW: It is recommended to use a CDN service (e.g. Cloudflare) in order to speed it up even more.

Local Development Setup

For local development, you can make use of the included docker-compose.yml

  1. Update the container name in the yml file.
  2. Download and install Docker Desktop.
  3. Adjust the $the_page_url in the config.php temporarily to "/".
  4. Run docker-compose up -d in the terminal at the project's root directory.
  5. Open the project at localhost:80 (mind that you might see an SSL error - should be no blocker),
  6. Happy coding and testing.

Contributing

Anyone is welcome to contribute, but mind the guidelines:

License

The code is available under the GPL 3.0 license. You can basically do anything with it, but mind that if you want to distribute your work based on this code, your work needs to be GPL licensed as well. This means that you can easily build your website with it, since this is no distribution. Distribution would be the case, if you sell a project based on this code to others or if you create public projects (no matter if you sell them or not). Even this would be all fine, as long as you license those projects also with GPL. :) Check the license file for all details.

Inspired by

This code has been inspired by the HTML5 Boilerplate.

php-microsite-boilerplate's People

Contributors

dependabot[bot] avatar jekuer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-microsite-boilerplate's Issues

Add TailwindCSS support

TailwindCSS introduces a new way to build webpages very fast.
Still, it breaks with common conventions regarding CSS (keep the styling in the css file and not the HTML).
The boilerplate (since it is meant for building simple websites fast) should support TailwindCSS, but do this in an optional way, so no one is forced to use it.

little comment issue on 1.4.4

Just wanted to start with the boilerplate as a playground but because of an wrong comment tag the site wont show.

In lib/url_parsing.php on line 144 there need to be the end of the comment not as it is, one line above i guess.

bet regards and thank you very much for providing this boilerplate!

Remove AMP support

AMP will be no longer pushed by Google.
Since the included caching solution (especially combined with a strong CDN) provides more or less the same performance (without the downsides), V2 will no longer support AMP.

CSS and JS optimization via build

Since we aim to support TailwindCSS, we will need to include some build magic. At least for the CSS optimization with Tailwind. Doing so, it makes sense to also include some minification process for the JS folder.
Combined with better documentation, this enables people to work on the code without the need to minify files locally.
However, it will require NodeJS - locally if you run it there or during a deployment step, which should also be prepared.

Add Gettext functionality

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Enhance internationalization by adding Gettext functionality.
This way, one could decide, whethere he/she wants to use different pages per language or use the same page with have a translated .mo file. The latter one makes it easier to translate a lot of text in many languages fast.

Still, no usual setup for a microsite and therefore low priority.

Routing not working

Hello, unfortunately the routing on my vhost does not work, likewise on my other webspace it does not run. I proceeded exactly as described in the blog.

YouTube Load on Click

Add functionality to include youtube videos, which load on click only and therefore do not block any other loading steps.

Exposing Directus part as standalone library

Hi, I have one question, not really an issue or similar.

I see that you have Directus as an option in your boilerplate, and since my PHP skills are not up to the task I was wondering do you maybe have plans(or any pointers in the right direction for DIY approach) for exposing the Directus part of your boilerplate as standalone library?

Just by reading the code I can say that I get what is going on, but it's impossible for me to somehow extract only the Directus part and use it standalone.

Thanks

Service Worker with webm and mp4 videos

I have embedded a video of about 6mb size, but it is not saved by the cache in any form. No MP4 no WEBM. I always get the following error: serviceworker-cache.min.js?v=5.0.13:1 Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Partial response (status code 206) is unsupported.

Bildschirmfoto 2023-10-16 um 14 43 57

Update Directus language limiter with deep param for V9

With a stable Directus V9, we need to update the function to limit the Directus call to the current language.
With V8, this can be done via the lang param. V9 will need the new deep param.
Afterwards, the workaround, which strips non-active language items, can be removed.

Deprecated warnings

@jekuer Thanks for providing this starter!
I don't know if it's the PHP server I'm running, but I'm getting a bunch of these deprecated warnings:
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /Volumes/Evo/Sites/php-microsite-boilerplate/lib/gettext/gettext.inc on line 92

I tried Docker, but it fails because I have an ARM Mac and the container doesn't support it even if I specify arm64 as a platform.

I have not yet tried Valet. Just testing using this VS Code PHP server extension https://marketplace.visualstudio.com/items?itemName=Anuragsingk.anuragsingk-phpserver

Create tutorial

A detailed tutorial should guide through the initial setup of the code.
Not yet sure if via the readme.md, a specific folder (with docs included) or only via the demo page.

Add an automated Language Switcher

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

Since it already includes multilanguage functionality, it would be a useful addition to create a component for a dynamic language switcher.
One could define more details per language, like its name or a flag image, which then could be drawn automatically into some kind of a switcher/dropdown.

This comes in handy, when dealing with more than 2 languages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.