Is the PHP client for the LXD API good?

Hi there,

The LXD documentation refers to several implementations of LXD API clients on different languages, however, there is none specified for PHP.

I have found this on Github:

Which seems to be quite up to date…

I was wondering if anyone had any experience with it.
Or if there’s a good reason for it not to be listed, then which one of the listed implementations/languages do you recommend.

Thank you.

@turtle0x1 is on this discussion forum.
They may want to chip in on this.

1 Like

Thanks @simos


Yeah i maintain that library now, i forked it from the original maintener as there wernt merging pull requests!

LXDMosaic uses it for communicating with LXD nodes and have had no complaints, occasionally i discover bugs and fix them (E.G couldnt create container from snapshot before)

I havent submited them to be “official” and i think the only special things about “official” bindings is that they were written by @stgraber

1 Like

I think you’re doing a fantastic job keeping it updated @turtle0x1, is there anything I can do to help you?

How do you think I should approach its deployment?

I would really need to understand what you are trying to achieve properly, budget, throughput etc but I have some ideas, at work currently ill take a look when I get home later (around 9 / 10 BST)


Also take a look at deployments in LXD mosaic, you have other issues to consider around phone_home and things like that

Looks pretty good!
What is docker used for?

It used to be used as a way to deploy LXDMosaic its not any more, but i left an open issue to try and get some contributers

OK, fantastic, I was afraid I would have to run Docker inside the LXC container…

No need for that!

LXDMosaic is not a required component for php-lxd i was only mentioning it so you could take a look at some of the problems I had to solve as part of the deployments functionality

1 Like

Yes I understand, but it’s beautiful addition to a LXD cluster and clients will love to see some graphics :grinning:

Yeah im going to merge the LXD cluster tweaks soon which includes:

  • Showing clusters
    • Including group different clusters (so if you have 3 different clusters it will recognise that)
    • there members & if they are a database node (and soon operation socket node)
  • Prevents a container showing all on hosts of a cluster
  • Auto discover & add cluster members (when you add one host in a cluster it will add all the other cluster members for you)
  • If i can get it working properly adding a standalone host into a cluster

So if your deploying this any were for clusters your better of waiting as the install script and upgrade path is going to change aswell

(also if your selling it, please consider buying me beer)

I see… would you be interested in adding to LXDMosaic features like:

  • Auto-healing
  • More complex than round-robin methods for deploying new containers( like based on load or other constraints)
  • Rollbacks and automated deployments.

You know, all these features that made K8S popular and are probably never gonna make it to LXD because it goes against its minimalistic design. approach…


Most of these things wont be available for LXD until it exposes CPU load information, I have thought at great length about some of these things (E.G deployments is my attempt to start this)

Without CPU load information you can only base it on memory and id ague that most apps need to scale based on CPU load and not memory

But there is a good reason that CPU load isn’t included and thats because it makes things slower :man_shrugging:

You can always use an agent script for that, these are minimal…
Anyway, CPU load is just one factor, the ideal would be to use any input…

For example, Prometheus exporters could be used:

You can’t use an agent script because you have to enable CPU load avgs in LXCFS which I believe you have to re-compile yourself

You could use them on the host, after all, you want to know the whole load on the host in order to decide which host to create a new container on, right?

Thats one of the more “boring” applications yes, i am far more interested in container loads

hehehehe, right!

What if I did everything on the boring side and you just add it to Mosaico?

BTW, maybe there’s a simple way to pull data from top/htop?