Download the PHP package nikomtis/phbeam without Composer

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

PHBeam Engine

PHBeam is simple and fast PHP micro-framework. It has no any admin panel. All data and config stored by PHP or JSON files.

It is good for building sites with dozens of pages and even with small product catalogs or galleries.

Requirements

You need a web server with PHP >= 5.4. No database required.

Installation

PHBeam can be installed in one of the following ways:

1. Using Composer (Recommended):

2. Cloning the Git Repository:

3. Manual Installation:

Post-Installation Configuration:

For all installation methods, configure your web server to use public/index.php as the entry point. This typically involves setting the DocumentRoot or equivalent directive in your web server's configuration.

Setting up your project

To create a website with PHBeam Engine you should follow these steps:

Let's review all these steps one by one.

Adding routes (menu items)

Any webpage can be displayed for users only if it presents in one of the menu files.

menus/ directory stores menu files with website routes. We have one menu named main out of the box. Let's look into the file main.php:

There is only one menu item, or route.

Each key on the first level of the array is the page URL. Array element having empty URL matches website home page. Leading slashes are skipped by router.

Each menu item contains 4 fields:

Feel free to add your own fields that can be used, for example, for special navigation menu styling or scripts.

If you want to add a new menu item for some page, menu file will look like:

In "Creating modules" section we will see how to render navigation menu.

Registering new menu

If your website have only one navigation menu (Home, About, Contacts and so on), you have to add menu items to main menu file. But you may need to have more than one nav, e.g. secondary menu in the sidebar. Then create new menu file secondary.php in menus/ directory and register it in config.php:

Filling site with content

content/ directory stores files that presents webpages content.

Each page may have up to 3 files. Look to example for page named "home" (menu file stores page names):

So to add a new page you should create at least one file with name that you spicified in menu.

Also there is a special page named "404". It will render if there is no menu item for requested route. You can operate with it's files too.

Defining page layouts

layouts/ directory stores page layouts. Layouts are wrappers for your pages content.

There is layout.php file that contains primary markup for your website. This is right place for adding fonts, stylesheets and scripts. You can use phb_insert_css() and phb_insert_js() functions to add local CSS and JS files. If you want to add stylesheet from public/css/main.css file, just do something like this:

and it will be rendered as:

In the code above you can see "v" URL parameter. It is timestamp when file was last modified. It helps to clear browser cache when you update your stylesheet.

phb_insert_js() works similar. This code:

will be rendered as:

Custom layouts

You can add different layouts that will be used by different pages.

There is bare.php layout out of the box that renders webpage content directly and does not affect to page view; it used by all pages by default (default layout can be changed in config.php file, see default_layout option). But you can add one more layout for wrap some pages with for example div with container class to limit content width. Just create file container.php (you may choose any name) with code:

and then specify container layout (without extension) for any page in menu file.

Layout for 404 page can be specified in config.php - error_page_layout is what you need.

Creating modules

modules/ directory stores files that can be included in any place of your website.

Let's look how to add a navbar module.

First we need to create navbar.php file in modules/ directory:

What we are using in this file:

Now you can just insert `` in any place of the page file (or even in other module) to render navbar.

But it will be more comfortable to use module positions.

Using module positions

Let's upgrade our layouts/container.php custom layout (Bootstrap CSS classes are used):

We can use phb_get_position_modules('sidebar') function to check if is there any modules in sidebar position for current page and prevent rendering empty sidebar.

Insert `` to specify where modules should appear.

Then configure pages to use container layout by editing menu file or by setting default_layout option in config.php file.

And define this module for sidebar position in content/home_modules.php:

Passing data to modules

You may need to render similar but not equal modules on different pages, for example page title with background image. Let's see how to do this.

Create modules/fancy_title.php file:

And add it to content/home_modules.php:

Also if you do not want to use position, you can pass params to module with second parameter:

Changing modules classes prefix

When using position to render a module, it will be wrapped in div with prefixed CSS class. For example, if your module file is navbar.php, CSS class will be module_navbar.

You can change classes prefix in config.php by editing modules_classes_prefix option.

Allowing URL params

PHBeam router strictly checks URL matching with aliases in menu files. If there will be only one excess character, you will see 404 error page. All URL params will be blocked.

But if you want to allow opening website pages with URL parameters, add needed params to config.php. For example, to allow URLs like example.com/about?yclid=123123 (such URLs are used by Yandex.Direct) do this:

Working with resources

In PHBeam you can store custom data arrays: small product catalogs, photo galleries, news feeds and more. You can use PHP or JSON files for that.

PHP resources

Let's add resource for two products.

Create resources/catalog_iphones.php resource file:

Then create modules/catalog.php module:

And insert `` in the right place on your page.

phb_get_data_from_php() function returns array with data from specified PHP file. We can walk by array and render some HTML code for each array element.

JSON resources

You can use JSON resources as well. In this case your resource file resources/catalog_iphones.json will be like:

Instead of phb_get_data_from_php() function you will need to use phb_get_data_from_json().

License

MIT Licensed.

Copyright © 2018-2023 Nikita Privalov. All rights reserved.


All versions of phbeam with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
ext-json Version *
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 nikomtis/phbeam contains the following files

Loading the files please wait ....