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

Free PHP Library to Read & Write Visio Diagrams

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

What is PHPVisio Library?

Nowadays, making top-notch diagrams and flowcharts is crucial for lots of projects. While Microsoft Visio has been the standard choice for this, what if you need a free option that works well with PHP? Meet PHPVisio, a robust PHP library made by PHPOffice. This tool lets developers easily make and edit Visio files. It also lets you export diagrams to different formats like PNG, JPEG, PDF, and SVG. It is also very easy to import external Visio files for further manipulation. It 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.

PHPVisio is a robust PHP library that allows software developers to interact with Visio files (VSD and VDX formats) through code. It empowers you to effortlessly generate, adjust, and retrieve data from Visio files. This makes it perfect for tasks like creating diagrams, generating reports, or visualizing data in applications. The library works with both VSD and VDX formats, ensuring it can seamlessly integrate with different versions of Microsoft Visio. If you are a PHP developer working with Visio files, the library It is a handy resource. It helps you handle Visio files programmatically. With PHPVisio, you can easily create interactive diagrams, pull out information from current ones, or convert diagrams into different file types. The great thing about PHPVisio is that it’s open-source, regularly updated, and comes with clear documentation. This makes it a dependable option for all your PHP-based diagramming tasks.

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