Download the PHP package noki/laravel-php-graph without Composer
On this page you can find all versions of the php package noki/laravel-php-graph. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download noki/laravel-php-graph
More information about noki/laravel-php-graph
Files in noki/laravel-php-graph
Package laravel-php-graph
Short Description PHP Graphing Library that creates graphs in Laravel
License MIT
Homepage https://github.com/novakurosevic/laravel-php-graph
Informations about the package laravel-php-graph
Laravel PHP Graph Lib
π History of PHP Graph Lib
The first version of PHP Graph Lib was created by Elliott Brueggeman in late 2007 π β almost 20 years ago! Good things really do stand the test of time.
You can thank Elliott Brueggeman by giving stars to his repositories or following him. Remember, he created this library under the MIT License and made it freely available. Today, it remains one of the best PHP libraries for creating graphs and pie charts under the MIT License.
Since 2007 and the first version of this library PHP versions have changed and so the library evolved. Current version is compatible with PHP 8.2.
Current repo is forked from repository of Troopster19 and at the moment of forking code was under MIT licence.
β What does this package do?
This package allows you to create graph and pie chart images. You have several options for handling images, including:
- Displaying image from php memory
- Save image to storage in Laravel and later handle that image
- Save image to public directory in Laravel. This way you have public access to this image. This package provides URL for public images.
[!WARNING]
Why Check Out This Package
- Few Laravel packages provide both graph and chart generation plus image export support.
- Itβs lightweight, easy to integrate, and released under the MIT license for full flexibility.
π Installation
Requirements
- PHP >= 8.0
- Laravel >= 9
- PHP Extensions:
- GD library (
ext-gd)
- GD library (
Composer Installation
βοΈ PHP GD Extension Setup
Linux (Debian/Ubuntu)
`
Example for PHP 8.3 β be sure to use the correct package names:
First, check your PHP version:
Then install GD for your version:
To verify if GD is installed:
macOS (with Homebrew)
The GD extension (
gd) is bundled with PHP on macOS. No extra installation is usually required.
To confirm GD is enabled:
Windows
- Open your
php.inifile. -
Ensure the following line is uncommented (remove the
;at the beginning): - Restart your web server (Apache, Nginx) or PHP-FPM.
Verify installation
Run the following command to check if GD is enabled:
π¦ Usage
Namespace
1. Create a private graph (not publicly accessible)
With line
it is set file name without extension or directory root. Parameter 'F' is used for output to file. This file will be saved in storage/app/private/php-graph-data directory inside Laravel.
File will be saved at that route and in variable $file_path will be set route to graph image.
Important notes:
- Only ASCII codes are allowed in texts in PHP Graph Lib.
- Since the output image format is always PNG, you do not need to set a file extension β any extension you provide will be ignored and
.pngwill be automatically added.Also, if you include a directory path in the file name, it will be removed, because all images are saved in the
storage/app/private/php-graph-datadirectory.
2. Create a public graph (publicly accessible)
Use same code as above for graph drawing just change last line
This way image will be saved to public/images/php-graph-data/ directory. This image will be publicly accessible. In variable $file_url will be returned URL to this image.
Important note:
- Only ASCII codes are allowed in texts in PHP Graph Lib.
- Since the output image format is always PNG, you do not need to set a file extension β any extension you provide will be ignored and
.pngwill be automatically added.Also, if you include a directory path in the file name, it will be removed, because all images are saved in the
public/images/php-graph-datadirectory.
3. Save image in PHP memory and display it without save to server
This is example of creating image from Controller.
-
Create route in
routes/web.php - Create controller in
app/Http/TestController.php
Summary of options
-
Save to file for internal use:
-
Save to file and file can be publicly accessed:
- Save to memory
π§ͺ Examples
Example 1 - Graph
Creates graph:
Example 2 - Graph
Creates graph:
Example 3 - Graph
Creates graph:
Example 4 - Graph
Creates graph:
Example 5 - Graph
Creates graph:
Example 6 - Graph
Creates graph:
Example 7 - Graph
Creates graph:
Example 8 - Pie Graph
Creates pie graph:
Example 9 - Graph
Creates graph:
Example 10 - Stacked Graph
Creates graph:
Example 11 - Graph
Creates graph:
π Error Handling
- If the GD library cannot be loaded, a
PhpGraphExceptionwill be thrown.
π§© Integration with Laravel
You can easily use this package in your controllers, services, or jobs by importing the relevant namespaces:
Once imported, you can create graphs and pie charts directly in your application.
π License
MIT License. See LICENSE.md for details.
π Contributing
Feel free to fork and submit a PR! Bug reports and feature requests are always welcome.
π Author Of Php Graph Lib
π Contributors
- Novak UroΕ‘eviΔ
- James Wakelim
- Petr Hurtak
- PΓ₯l Saugstad
- Ahmet Gencoglu
- David Gil de GΓ³mez IV
- Manuel R
- Troopster19
π Changelog
Please see CHANGELOG.md for recent updates.
All versions of laravel-php-graph with dependencies
ext-gd Version *