PHPackages                             rikudou/php-scad - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rikudou/php-scad

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rikudou/php-scad
================

A PHP wrapper around OpenSCAD

62732PHP

Since Jan 17Pushed 1y ago4 watchersCompare

[ Source](https://github.com/RikudouSage/PhpScad)[ Packagist](https://packagist.org/packages/rikudou/php-scad)[ RSS](/packages/rikudou-php-scad/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PhpScad - 3D modelling using OpenSCAD in PHP
============================================

[](#phpscad---3d-modelling-using-openscad-in-php)

Ever wanted to create a 3D model in php? Sure you did, *everyone* does. And now you can.

How does it work?
-----------------

[](#how-does-it-work)

It generates OpenSCAD code that in turn creates the STL 3D model. OpenScad basically looks like this:

```
translate([10, 0, 0]) // translate([x, y, z]) - moves the model by given coordinates
cube([10, 10, 10]); // cube([width, depth, height])

difference() { // only the difference between child objects is rendered
    cube([5, 10, 15]);
    cylinder(10, 5, 5); // cylinder(height, bottomRadius, topRadius)
}
```

This is the resulting 3D model preview:

[![OpenSCAD example](/doc/img/example-openscad.png)](/doc/img/example-openscad.png)

### So why use php if you can already create the model using code?

[](#so-why-use-php-if-you-can-already-create-the-model-using-code)

1. PHP is full-blown general-purpose language with a lot of documentation around the internet
2. There are full-blown IDEs that help with code completion
3. PHP supports more paradigms, like object oriented programming
4. Saner parameter names - for example the `cylinder` signature is `cylinder(h, r, r1, r2, d, d1, d2, center)`compared to PhpScad version - `new Cylinder(height, radius, bottomRadius, topRadius, diameter, bottomDiameter, topDiameter)`
    - note that in both OpenSCAD and PhpScad version many of the parameters are optional
5. Created an interesting parametric shape? Cool, share it via composer because PHP has a package manager!

### So how does the example above look in PHP?

[](#so-how-does-the-example-above-look-in-php)

```
