Running scripts on source upload - php

I'm using Netbeans 6.9 to develop PHP code; testing happens locally on my PC (XAMPP); once done code is uploaded using Netbeans upload facility to the production web server.
I recall reading about Netbeans capabilities running scripts when "building" the project, and looking for a primer about it.
Particularly I'm looking for some ways to achieve the following, right before uploading files to the production server:
- strip comments from PHP sources
- minify PHP
- minify Javascript & CSS
Can someone enlighten me?

I think what you may be aiming for is a tool like Apache Ant. It runs an XML with several targets which usually are nothing more than some shell scripts.
So this means;
Setup Apache Ant
Find some CLI/shell scripts to do the jobs you mention
Create an ANT build file with the FTP upload in the end
Run the ANT file
More info on Apache Ant; http://ant.apache.org/

Related

PHP formatting in VSCode on remote Workspace without using Composer

My Setup: Ubuntu 20 with PHP and Composer
My Editor: VSCode with SSH FS extension to access remote workspace.
My Task: do some PHP stuff, mainly Wordpress Themes
My Problem: no PHP Formatter extension works on the remote Workspace
I tried to use: PHP-CS-fixer, Prettier with PHP plugin, phpfmt, phpcs, PHP Formatter...
Some of them will even not work on my local Workspace.
I can't install new Code on the remote Server (Composer), so i need a way to format PHP files just out of the Box like HTML or JS.
But meanwhile i think, this is not possible.
Solution: use Ubuntu to connect to the server and mount that folder in workspace, let VSC think it is a real local folder :-)
The problem with most formatting extensions is that they expect the files to be on a local drive, as in being mounted outside VS Code, including network shares by any NodeJS program (and therefore VS Code extensions). The extension uses the extension API's FileSystemProvider to provide FS access to VS Code. It is only recently that they added a way for one extension to use file systems provided by other extensions, and it's even more recent that they started pushing extensions to make use of this.
Sadly enough, not every extension developer might start using it, and it's especially tricky for extension that use native/external programs. That includes most language-servers and formatters.
For your use case, there are two solutions though:
Mount the folder on the OS level (e.g. sshfs) and just open it as a regular directory in VS Code, as another answer suggested
Use VS Code's Remote SSH, which actually runs the extensions on the server, therefore skipping the whole "files aren't on a local drive" problem

How to prototype with PHP and HTML5 forms when I cannot view the result?

I recently started PHP (I am a beginner) and I wanted to create a form with HTML to add numbers together. However, when I send queries to PHP it shows my source code (because it is not a server - file is run locally). I was wondering would it be possible to preview my PHP's code result on a website of some sort or even better on my computer? Do you know any services or ways to accomplish this, preferably free of charge?
To run php files online, go to Write Code Online.
As long as you can install programs on your computer, you should install a web server to run php files locally. To run any basic app, especially if it uses forms, you will use multiple php files and the testing will be too complex to run online. If you are using windows, install wamp. For mac, try mamp.
you seriously require some help :-)
First, PHP is a server side scripting language, so it requires server (like Apache, which you can install using the wamp or xampp installers) Try to search google on how to install them on local computer.
Second, their are some online PHP editors, like http://www.compileonline.com/execute_php_online.php or writecodeonline .com and many others. It may not replace the server but helps to write the PHP code and execute it for the sake of practising.
Also, it is better if you read some tutorials about PHP. One tutorial I can point you to is the http://www.w3schools.com/php/php_form_complete.asp which is related to question.

NetBeans deploy PHP application

I come from a .NET visual studio background and am learning PHP (with CakePHP) using NetBeans.
In visual studio there is a publish option that allows you to publish your application via file system tranfer (essentially just spits out the application in the form that is needed for it to run on a webserver). Is there anything similar in netbeans?
I do all my dev work on the built in PHP webserver, and would like this file system transfer option so I can just copy and paste the files wherever I want to.
I can't just copy the files from my working directory as it contains all the version control meta-data.
I am aware of the FTP and the remote server upload option, but I was hoping for the simpler approach as above.
Maybe the "visual studio approach" as above is not suited for a PHP environment, in that case I could use some pointers/tips!
Heres how to deploy to a remote server using NetBeans https://netbeans.org/kb/docs/php/remote-hosting-and-ftp-account.html

Web Development - Saving/Uploading files to Linux server from Windows

I will be developing a new project in PHP. The scripts will need to be tested on Linux and I will be coding on windows. The script cant be tested on Windows because I will be running Asterisk server on Linux. The script I will write will communicate with the Asterisk server. It will be uploading the files specific directories on Linux for testing. There are three directories I will be working on:
/var/www/
/var/www/admin
/user/local/bin/ - Daemon (process) script will be written in PHP.
It will be annoying I have to keep uploading files to the specific directories via FTP client. So what is alternative good solution to upload files easily to Linux server while im coding on Windows?
Investigate setting up an SMB share on the Linux machine that you can map as a network drive on your Windows machine.
You can install a samba server and mount the relevant directories as drives on your windows client.
As an alternative, you can use the deployment capabilites of your IDE
Eclipse PDT
see also this answer How do I add FTP support to Eclipse?
Netbeans
I know this is an old post but just in case someone else comes across it....Use something like Netbeans so that when you save your code your files will be automatically saved to the server

Developing PHP with Eclipse on a remote server (FTP) on Windows

I'm a real klutz when it comes to Eclipse, but I'm also poor, which is why it is the option I've chosen.
I've installed Eclipse 3.5, Eclipse for PHP, and RSE. I've actually gotten to a point where I can create a new (local) project and download all files to my local (Windows) computer. I'm not running any kind of web server on my local box, and am hoping to keep it that way for now.
I've imported my remote folder into my local project, where I can see all my PHP files and edit them. But of course, when I save, it just saves the local copy. Is there no "put" command? Can I not save straight to the server? Or perform an immediate sync of that one file? I certainly wouldn't want to have to perform a complex sync operation after every little incremental change.
I have no idea what RSE really is, nor how it works, and the documentation is, well, cloaked at best, non-existent at worst. Does anyone have some tips for me? What should my workflow be (barring any local server to test)?
Ideally, I would love to be able to open up the entire "project" directly from its location on the remote server and avoid dealing with a "local" copy altogether. Failing that, I would be willing to "get" the entire remote site once, and then manually "put" individual files that I change locally back, provided it's not a cumbersome process. Am I asking too much? Dreamweaver operates this way, but it's support for PHP is limited at best and can't be considered a full-fledged IDE...
I use WinSCP and enable remote synchronization.
Everything that changes on the local system is automatically synchronized trough SCP/FTP onto the server.
Looks like RSE might be overkill for your needs. Here's a similar question and popular answer to your problem of uploading from Eclipse:
How do I add FTP support to Eclipse?
Secondly, you could try out a version control system like SVN - it would take a little bit of time and work to set it up but probably be far more useful than getting RSE going and then you could develop locally, commit your changes to the server and then update the workspace on the server.
Thirdly, there are other IDEs out there, like Netbeans, with built in support for working on remote files.
Sorry to drag up an old topic but Remote System Explorer is exactly what you need. No need for sFTP or a Shell. Setup the connection in the RSE perspective just like you normally would using your sFTP/SSH client.
Open the folder for the first time and you get the login dialog. Enter your credentials. Store them as needed.
Now navigate to your development files and double click or right click to open the file. Eclipse caches a local copy till you save, Ctrl-S.
Need to do some shell work. Right click on a folder and Launch a Terminal. If your files are source controlled, such as svn, you can checkout or update from the terminal.
I use to have Putty, FileZilla and a host of other editors and utilities. Now I never leave Eclipse. SQL, Shell, sFTP, PHP, CSS/HTML, C/C++, Droid, all within Eclipse.
I tackled the same problem recently. I got a web site hosting company and was using SeaMonkey and developing the code on the 'production server' and learned to do development on a 'development server' and then upload the debugged, working stuff to the production server.
So I use Xampp (it's a good, and FREE, local web server you can easily install on your laptop) and I use NetBeans to develop. Netbeans is better than Microsoft tools -- no ballmer involved in the deal.
xampp uses Apache as the (local) web server and provides Mysql and PHP server-side-scripting support.
The quality of these two is HIGH. Just excellent stuff. You will want to get a local web server running on your laptop, do your development locally, then upload using ftp or the Netbeans environment, the files to your 'production web server.'
I messed around with a lot of different unrelated pieces trying to put a local web server, debugger, mysql database together and then got really lucky and found xampp and then NetBeans.
I think #Ɓukasz's note deserves to be an answer on this page - it would have saved me a great deal of time, so hopefully it will do the same for others:
Here is great tutorial for Eclipse: How to setup Eclipse with PHP PDT, Remote System Explorer, Theme Manager, and Drupal Plugins Eclipse + PDT + Remote System Explorer allows you to develop PHP applications remotely.
I will add that downloading and using the smaller Eclipse for PHP Developers and thus skipping step 2 on the blog works just fine.

Categories