I don't think you can do this directly in PHP. However, there are command-line tools available that could do it for you.
What you can do is place the executable for such a tool inside your project and run it from inside your project against the given file. You can execute server commands from PHP as well.
Maybe this will do the trick for you: https://www.verydoc.com/blog/is-there-an-api-or-library-for-converting-dwg-to-any-standard-image-format.html