Download the PHP package reallifekip/grid-map without Composer

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

GridMap

Language: English | 繁體中文

A lightweight, zero-dependency PHP micro-library for grid slicing. It divides a fixed-size plane (e.g., 1920x1080 canvas, video wall, media composition, dashboard, or layout system) into a grid according to specified proportions, then sequentially “fills” rectangular slices into available cells and returns their pixel coordinates and sizes.

GridMap uses a simple row-major first-fit scanning algorithm to find the first available area that can fit a slice of the requested grid width/height. If successful, the area is marked as occupied and the next slice is processed. If a slice cannot fit, an exception is thrown.


✨ Features Overview


📦 Installation


🚀 Quick Start

Example output (actual may vary depending on allocation):

The above width/height are actual pixels, calculated by dividing (total_canvas / grid_count). For example: 1920/24=80, 1080/12=90. A 6-grid width = 6 × 80 = 480 pixels; a 6-grid height = 6 × 90 = 540 pixels.


🧠 Core Concept

Term Description
area_w, area_h Total canvas size (pixels)
grids_w, grids_h Number of grid divisions (horizontal / vertical)
slice [cw, ch] Slice rectangle defined in grid units, not pixels
return areas[] Each placed slice, with x,y,width,height (px)

Steps (simplified):

  1. Compute all grid line coordinates: cols[x] = intdiv(x * area_w, grids_w), rows[y] = intdiv(y * area_h, grids_h)
  2. Use a 1D array to mark whether each cell is occupied
  3. For each slice:

    • Scan row-major for the first fitting location
    • Check if all covered cells are free
    • Mark occupied and convert to pixel rectangle
  4. Throw exception if slice cannot be placed
  5. If leftover space exists, trigger an E_USER_NOTICE (informational, can be ignored or handled)

✅ Example Use Cases

Use Case Description
Media/Video wall Automatically arrange multiple video sources
Video compositing Map multiple tracks into fixed canvas coordinates
Realtime dashboard Auto-generate initial layouts for widget cards
Game/Level editor Plan map or scene block placements
Ad screen layout Place multiple ad creatives into grid layout

🛠️ Advanced Example: Mixed Sizes & Error Handling


⚠️ Notes

  1. Each slice must be [cw, ch] of two positive integers
  2. cw cannot exceed grids_w, ch cannot exceed grids_h
  3. Strategy is “first feasible placement”: not optimized for space, just deterministic
  4. For “optimal packing / rotation / reordering”, preprocess slices (e.g., sort by size)
  5. Returned array indexes correspond 1-to-1 with input slice order
  6. To ignore the unfilled notice, define a custom error handler or suppress E_USER_NOTICE

🔍 Return Data Format


🧪 Testing Suggestions (example)

You may write PHPUnit tests to verify:


📄 License

This package uses the MIT License – Free for commercial use / modification / distribution, just keep copyright notice.


👤 Developer Info

Author: Kip ([email protected]) GitHub: @ReallifeKip

If this project helps you: feel free to Star, share, or suggest improvements!


All versions of grid-map with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
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 reallifekip/grid-map contains the following files

Loading the files please wait ....