1. Products
  2.   Diagram
  3.   PHP
  4.   PHPVisio
 
  

Free PHP Library to Read & Write Visio Diagrams

Open Source PHP Visio Library that allows Software Developers to Create, Edit, Manipulate and Export Microsoft Visio Diagrams inside PHP apps.

In today's digital age, creating professional-quality diagrams and flowcharts is an essential part of many projects. Microsoft Visio has long been the go-to tool for this purpose, but what if you're looking for an open-source alternative that seamlessly integrates with PHP? Enter PHPVisio, a powerful PHP library developed by PHPOffice that allows software developers to create and manipulate Visio files with ease. It supports exporting diagrams to various formats, such as PNG, JPEG, PDF, and SVG. You can also import external Visio files for further manipulation.

PHPVisio is a powerful PHP library developed by PHPOffice that enables software developers to work with Visio files (VSD and VDX formats) programmatically. With PHPVisio, you can create, modify, and extract data from Visio files seamlessly, making it an ideal choice for applications that involve diagram generation, reporting, or data visualization. The library supports both VSD and VDX formats, ensuring compatibility with various versions of Microsoft Visio.

PHPVisio allows you to create basic shapes like rectangles, circles, and lines, and position them within your diagram. You can set attributes such as fill color, border color, and text labels to customize your shapes according to your project's needs. This flexibility enables you to craft visually appealing diagrams effortlessly. The library is a valuable tool for PHP developers who need to work with Visio files programmatically. Whether they want to create dynamic diagrams, extract data from existing ones, or export diagrams to various formats, PHPVisio simplifies the process. Best of all, its open-source, actively maintained, and well-documented, making it a reliable choice for your PHP-based diagramming needs.

Previous Next

Getting Started with PHPVisio

The recommend way to install PHPVisio is using Composer. Please use the following command for a smooth installation.

Install PHPVisio Library via Composer

composer require phpoffice/phpvisio
You can also download it directly from GibHub.

Generate Simple Visio Diagram via PHP

The open source PHPVisio library gives software developers the power to create diagrams from scratch or modify existing ones using PHP commands. This is particularly useful for generating dynamic diagrams based on data. Moreover the library allows developers to create basic shapes like rectangles, circles, and lines, and position them within your diagram. They can set attributes such as fill color, border color, and text labels to customize your shapes according to their project's needs. This flexibility enables users to craft visually appealing diagrams effortlessly. The following example demonstrates how software developers can create a simple Visio diagrams inside their PHP applications.

How to Create a Simple Visio Diagrams via PHP Library?

require 'vendor/autoload.php';

use PhpOffice\PhpVisio\Diagram;
use PhpOffice\PhpVisio\Shape;

// Create a new diagram
$diagram = new Diagram();

// Add shapes to the diagram
$shape1 = $diagram->createShape();
$shape1->setWidth(100);
$shape1->setHeight(50);

$shape2 = $diagram->createShape();
$shape2->setWidth(100);
$shape2->setHeight(50);
$shape2->setOffsetX(150); // Position the second shape to the right of the first one

// Connect the shapes
$diagram->connectShapes($shape1, $shape2);

// Save the diagram to a Visio file
$diagram->save('my_diagram.vdx');

Layer Management inside PHP Apps

Effective diagram creation often involves organizing elements into layers. The PHPVisio library lets software developers create, edit and manage layers within their Visio documents, making it easier to work with complex diagrams. Developers can set the visibility and order of layers, allowing them to focus on specific parts of their diagram when needed.

Export Diagram to Various Formats

The open source PHPVisio library gives software developers the capability to export Microsoft Visio diagrams to other supported file formats with ease. Once the diagram creation is completed using the library, software developers can export them to various formats, including Visio XML (VDX), PDF and popular image file formats like PNG, JPEG, PDF, and SVG. This ensures compatibility with other software and allows users to share their diagrams with colleagues and clients effortlessly. It is also possible to import external Visio files for further manipulation.

Connecting Shapes in Visio Diagrams via PHP

One of the key features of Visio is the ability to connect shapes to represent relationships and flowcharts accurately. The PHPVisio library supports this by providing methods to connect shapes using connectors. You can define the type of connectors, specify their start and end points, and even customize their appearance. This makes it easy to create complex flowcharts and process diagrams programmatically.

 English