Download the PHP package paphper/paper without Composer

On this page you can find all versions of the php package paphper/paper. 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 paper

Paphper

Paphper is Static Site Generator written on top of ReactPHP.

Installation

composer create-project paphper/paper

Docker Support

You can use paper on docker too here are some additional steps -:

Development

php paper dev

This runs a development server at http://localhost:8888. This also looks for changes in the files in the pages folder and reflects in the browser.

Note: This does not watch for the changes in the layouts. So, if you make a change in the layout, you will have to modify something in your page to see the changes in the browser. You can change this port to your choice at /config.php.

Folder Structure

/pages

This is where all the pages for the site lives. .html, .md and Blade files are supported as pages. The folder structure of pages decides the routes.
For example:

/layouts

This is where all the layouts for the site lives. Only html files are supported as layouts.

/assets

This is where the images, css and other assets live

Note: All of these can be changed here in the /config.php.

<paper>

We include 'meta' for post in a <paper> tag. Meta here means whatever you want to be replaced in the content of the page.

{content} in the layout and layout in the <paper> tag are reserved and cannot be used to replace the contents in the page

The syntax in the template is {meta}. For example if you want to add title to a page {title}, add a

in your paper tag. and in your layout. You would add

This will generate

in the HTML.

Example paper tag

File types supported

Paphper supports three file types for now.

  1. Html
  2. Md
  3. Blade Templates

Image resize support

Paphper has support for image resizes as well from a single source file. You can reference size of an image and it will generate that size.
For example:
There is a file index.html and in referenced as /envelope_50x50.jpeg in index layout. This will copy the original file and also create a /envelope_50x50.jpeg in the given dimension.

For this to work. The image MUST be referenced as fiiname_widthxheight.jpeg. For example:
To generate a 50x50 dimension image for /envelope.jpeg, it must be referenced as /envelope_50x50.jpeg.

Building

php paper build builds html files into the build folder. Which can be specified here.

img

Advance Usage

I have tried to make this thing as flexible and extendable as it can be. Let me explain a bit of architecture to help me explain this.

Architecture

PageResolvers

PageResolver is a simple class that implements PageResolverInterface.php

This is the source of the route structure. The functions explained.

  1. getPages should return what pages are to be build. It should be a Promise that resolver to an array of strings.(pages).
  2. getBuildFilename(string $page) should return the file that this should be added the parsed content of the page to. MUST be a full path
  3. getBuildFolder should return the folder that should be created to place the file. MUST be a full path.

The default PageResolver used in Paphper is FilesystemPageResolver This scans the folder in the pages folder and retrieves that pages and decides on the files and folder to be created.

This can be extended to use, for instance, a mysql table with posts and create the page based on the uri of that post.

FileTypeResolver

Content is the class that interprets any file into HTML. It implements Contentinterface. The needs to have one function.

  1. resolveFileType(string $filename) when passes a filename should simple return a ContentInterface. ContentInterface returns promise that resolves to a string. This is the final content that will be written in the HTML file generated.

We have three FileTypeResolvers at the moment.

  1. HtmlResolver
  2. MdResolver
  3. BladeResolver

Paphper uses this interface to internally add support for multiple file types.

MetaInterface

Meta parser parses the meta in a page. The default meta parser is Paper Tag Parser which implements MetaInterfaec Paper Tag Parser as name suggests the <paper> tag on top of the files.

You can implement your own meta parser as well. The functions explained.

  1. getBody this should be able to get the body of the page without the meta that will be written to the HTML.
  2. getLayout this should be able to get the layout that will be used. In case of blade templates, this is not required because it is handled by blade itself.
  3. getLayoutContent should get the content of the layout so that the meta and content could be passed to this.
  4. get this should return meta value on passing the meta key
  5. getExtraMetas this is all the metas
  6. process returns a promise. Since we are working with promises for filesystem, the file has to be read once to process content of the page. If we process promises individually in every call it becomes hard to return as types and becomes a callback hell. Hence we call the process function to set all the properties.

Putting this together

We basically put this together to create a static site.

https://github.com/paphper/core/blob/master/paper#L26-L43. These are the defaults used in paper. You can customize and write you own. I am planning to add more. Let me know what should be added to this. Create a PR or issues for suggestions, contributions and feedback.


All versions of paper with dependencies

PHP Build Version
Package Version
Requires paphper/core Version 0.0.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 paphper/paper contains the following files

Loading the files please wait ....