Download the PHP package taujor/phpssg without Composer

On this page you can find all versions of the php package taujor/phpssg. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpssg

πŸ’– PHPSSG is open source and free.
If you find it useful, please consider sponsoring me to support continued development.

PHPSSG (Personal Home Page Static Site Generator)

A lightweight, PHP-native static site generator for building composable templates.
PHPSSG uses invokable component classes, output buffering, and plain PHP templates to provide a clean developer experience β€” no third-party templating engine required, but you are welcome to use one.


Features


Requirements


Quick start

Clone the skeleton template repo or visit the repo and click "Use this template"


Installation

Install via Composer:

Run a local development server:


Usage

Layouts

Layouts are typically Renderables:


Components

Components are typically Renderables (like layouts) or Composables :

Title and Subtitle are Renderables (in this example) they have their own respective template files, however our Heading class simply takes these two components and "composes" them into a new component (via string concatenation in this case). Hence it does not require its own template file but can still be invoked just the same as any other presenter.

The render method of Renderable extracts variables into the template and returns the output as a string.


Pages

Pages are typically Buildables, like Composables they are self-contained, and do not need separate view templates. They inherit the compile and build methods which output html files to the build directory (public by default):

Pages often combine components and layouts. The $data argument is passed to the page during the build process. $data is then passed to components via their respective __invoke() methods. Then finally the layout wraps the combined HTML content.


Utilities

Utilities are typically helper classes that provide additional functionality to phpssg. You can use utility classes to implement things like alternative renderers (twig for example), provide custom methods to your components, etc.

This utility class can be used to locate the root of a composer project, this example is derrived from the Locate utility class used throughout this project, see the "build scripts" section for details on how Locate is used for configuration.

You can even extend an abstract class such as Renderable to support entirely different templating systems such as twig or markdown and using your extended class in your components instead of the defaults. In a future release there will be separate offically maintained integrations you can install via composer that will extend PHPSSG's core features this way, but don't let that stop you from creating your own that are specfic to your individual project.


Views

Stored in src/views (by default). Only Renderables have view templates. Composables and Buildables don't require view templates. Views are plain php templates, I recommend their directory structure mirrors that of the Renderables in your presenters/ directory for example:


Hooks

Hooks provide lifecycle entry points for customizing the behavior of your components.
They are defined in the base Composable, Renderable, and Buildable contracts, and are automatically called at key points in the rendering or build process.

Hooks are optional β€” override only those you need.
They are always protected and are intended for internal subclass use only.


Composable Hooks

Composable components are pure PHP objects that produce HTML by combining other components.

Hook Signature Called When Common Use Cases
_beforeInvoke() void When the component is instantiated Set up shared state, inject defaults, or run dependency checks before the component is first used.

Example:


Renderable Hooks

Renderable components generate HTML from PHP view templates.

Hook Signature Called When Common Use Cases
_beforeInvoke() void On component instantiation Initialize configurations, register filters, or set default view variables.
_beforeExtract() (array &$data, string &$path) Before variables are extracted into the template Sanitize or transform $data, or modify $path to dynamically choose a template.
_afterRender() (array &$data, string &$html) After the template has been rendered Perform post-processing (minification, analytics injection, DOM mutation, etc.).

Example:


Buildable Hooks

Buildable components handle static file generation and support a full pre/post lifecycle around rendering and writing output.

Hook Signature Called When Common Use Cases
_beforeInvoke() void When the component is instantiated Initialize caches or configuration before any builds begin.
_beforeRender() (array|object &$data) Before rendering HTML Transform or validate dataset items before they’re rendered.
_afterRender() (array|object &$data, string &$html) After HTML is generated Post-process or filter HTML (minify, inject scripts, add metadata).
_beforeWrite() (array|object &$data, string &$file) Before writing to disk Adjust output path or organize files dynamically based on data.
_afterWrite() (string &$file, int|false &$bytes) After the file has been written Log results, update caches, or trigger notifications.

Example:


Build scripts

This is the entry point of the application often placed in the scripts directory at the root of your project. They call on Buildable presenters to generate html using the compile or build static methods. The compile method takes a target path relative to your build directory, the generated html will be sent to this path. The second parameter supports either an array or object containing data you would like to __invoke the Buildable with. The build method simply iterates over your dataset and runs compile on each item. You can also use placeholder syntax to use any top level value in your dataset to generate unique filenames. For example:


Project Structure

There are no mandated directory names or conventions, you can decide how you like to structure your project. However I have provided some sane default directories you can see in the next section that will work with zero configuration.

Suggested Structure

There are some directories PHPSSG needs to have around, those being a views, build, and cache directory (marked as REQUIRED). You are free to reconfigure them as needed but if they are missing the project will not work as expected. The cache and it's sub-directories are automatically created during runtime if they don't already exist.

Configuration

At the entry point of the PHPSSG application (commonly the build script) you can use the Locate class to tinker with your project layout.

As you can see above the Locate utility class provides static methods that can both override and return the configured location. Once an override is set further overrides will be ignored for the duration of the runtime, you can bypass this using Locate::reset() which will revert all changes to default.

Locate is used througout PHPSSG to get configuration data, it works lazily, inteligently setting defaults the first time it is called and caching them in memory, subsequent calls always return the cached location rather than whatever is in the $override argument or expected by default. Calling Locate::reset() clears this cache, setting each static variable to null. Then when a method of Locate is called again it will either cache and return it's defaults or use the supplied override.

Here is a list of Locate's default settings:

Default Configuration

Method Default Path Relative To
root() (project root) β€”
views() /src/views root()
cache() /cache root()
hashes() /hashes cache()
proxies() /proxies cache()
build() /public root()
engine() .php β€”

Contributing

Contributions are welcome! Philosophy:


Planned Features


All versions of phpssg with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
php-di/php-di Version ^7.1
friendsofphp/proxy-manager-lts Version ^1.0
composer/composer Version ^2.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package taujor/phpssg contains the following files

Loading the files please wait ...