Export project files as PHP

A nice feature would be the ability to export project files as php – or any extension for that matter. Choose from a drop-down list and hit ‘Export’. In fact, I’d be even so bold as to suggest the ability to export sections such as the header, footer and main blocks as individual .php files from the HTML panel as seen in the photo below where there are options “Change” or “Copy”.


Has been asked many times already… not going to happen any time soon

But it seems within the capability of the developers since I have, since posting, found that a bash script can do the conversion. At least provide an option “Use ext from script”, since not every project might need the facility, although I don’t see why not since HTML pages serve only to display markup in an age of active server pages.

For anyone who has run into an error using the Linux code provided on this page: https://bootstrapstudio.io/forums/topic/change-html-extension-to-php-solved/ here’s what actually works on Ubuntu/Debian:

for f in *.html; do mv -- "$f" "${f%.html}.php"; done

This is my script for changing the HTML extension to PHP, starting the PHP built-in server and opening the index.php page:

cd $1
php -S
for f in *.html; do mv -- "$f" "${f%.html}.php"; done

Make sure not to have any calls to scripts not available in your file or PHP will stop at the point where an include or require etc can’t be executed. I set the port to 5000 so as not to conflict with the Bootstrap Studio use of 8000.


1 Like

Yeah the bash script during export will work but php isn’t going to be supported natively out of the box.

I know BSS isn’t an IDE but since half the Web is PHP, I’ve created my mini environment by installing PHP CLI on Ubuntu, added the script above to create PHP files from the project output and now with a few more lines of code in a Bash shell script, I can now create very basic individual WordPress (or any PHP) pages from the different blocks of markup by copying the block and running the script to create and give the file created a name.

Eg, if I right click on the block and “Copy as HTML”, I run the script which asks for a name; In this case I enter “header” hit enter and the script copies the header text to a file named header.php and opens it in my editor.

So say I’m creating home.php, I click the block that contains what will fall between the WP header and footer, say , I copy as HTML and I double click my file.sh. The Konsole opens, I type home:

File opens in Kwrite (or the editor you choose to add to the script) and voila! edit away. Delete what’s to be deleted and add WP loops.
<?php get_header();?>
markup and text and other stuff is in here
<?php get_footer();?>

Of course, if you’re not working with WP, just edit the script to use <?php include 'header.php';?>, <?php include 'footer.php';?> or whatever your page names are. It’s so easy, even I could do it. It’s seven lines of code including the shebang.

PS: On Ubuntu, Xclip is what keeps the copied block in memory for access by the script; about 53kb of code if it’s not installed by default.