How to edit php files locally? [closed] - php

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
With HTML files, I can work locally and preview the files in my browser after I've saved and made changes (and use LiveReload), but with PHP the browser just loads the code. Do I need to run a local server to work on it locally, or is there an easier way?
The extent of my PHP is using include statements for headers and footers.

Yes you will need a local server to run PHP scripts locally. Check out MAMP for Mac or XAMPP for PC.

Yes, you'll need to install something such as WAMP

No - since php is a serverside interpreted language you have to run a server. The easiest way is to install xampp whick brings everything you need - apache, mysql, php.
On windows you could also install IIS server which is part of windows

You can very easily download and set up a server - and on that note, yes do do need to have PHP and Apache set up to have PHP working.
I would probably suggest something like WAMP - it is basically pre-setup and requires very little config to get up and running. This will come with Apache Server, MySQL and PHP set up nicely to work together and comes with a very easy to use point and click interface. Oh, and it even installs PHPMyAdmin so that you can easily work with your databases if you are not familiar with console controls.

You need to set up a server that can serve php requests appropriately. However, this is incredibly easy to do. Just google how to install a LAMP server (on Linux), or look into WAMP (on windows). If this is still too much for you, look into purchasing a shared hosting account or something. I have a small one for like $15 a year. They will have the servers set up with everything you need already; you'll just have to upload the files.

Yes, you need to run a local server to 'work with it'. I would suggest XAMPP. To actually edit the files, you of course need a text editor. Any editor will do as far as I'm aware, but I use Notepad++ myself, or even the NetBeans IDE.

Related

Questions about installing php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'd like to be able to run PHP application on my own windows desktop.
What are my options?
accodring to this reference, I have to install visual studio 2015 to able to do it. Is it the really necessary?
Why do they mention compiling php? it's a scripting language so am I still supposed to pre-compile it before running it?
Is Visual Studio the only editor or there are other suggested IDEs?
Do I have to run it on IIS, can't I install apache server on my desktop and run the php application on it?
The instructions you find on the wiki are for building PHP from source, but you don't have to do that to use PHP on Windows.
You can use one of the WAMP/XAMPP packages mentioned in the comments. That's definitely a quick and convenient way to get it working on your system. But if you really just want to put PHP on your Windows machine without using one of those, it really isn't too hard.
Based on your questions, including:
Why do they mention compiling php?
I think I can safely assume that you don't want to compile PHP. Fortunately, you don't have to.
Just go to the PHP for Windows download page and find the version that will work on your system. The "Which version do I choose?" in the left panel will help you figure out which one you need. These are pretty much ready to use, just extract it where you want it (I usually just do C:\PHP).
You will need to have the appropriate C++ redistributable installed before it will work. There are also links to those on the PHP for Windows page that I linked above. If you chose PHP 7 (why not?) it will be the VC14 version.
After you have installed the C++ redistributable and extracted the PHP zip file you downloaded, add the new PHP directory to your Windows path, and you'll be able to use PHP on the command line. You can test that it's working properly with php -v (displays the installed version) in a cmd window.
To configure your PHP installation, start with one of the provided ini files, either php.ini-development or php.ini-production. Make a copy of the one you want to use and rename it to php.ini.
Of course, this is only PHP. If you want to use it to with Apache or some other web server, you'll need to install that separately and configure it to use your PHP installation. It's not difficult after you have some experience with it, but I remember it being pretty frustrating to get it working the first time. The advantage to using XAMPP or similar is that includes Apache and MySQL with one installer. If you're just starting out, that's definitely the easiest way to get going.
As far as IDEs, there are various ones that support PHP. There are some free ones that are fine, if that matters to you, but all you really need is a good text editor.

How do I convert a php web application into a desktop application and retain database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
We have a web-application developed in PHP. But most of clients don't have internet connection all the time. So, is there way to convert the app into a desktop application so that it works stand alone and it syncs to web application whenever there is an internet connection? Currently I am testing it locally via xampp and it works but I dont want to have to install xampp or wamp on a clients pc. I am an amateur at coding FYI. I would appreciate any precise answer with example.
A nice and simple way to do that without having to go through XAMPP or LAMP installation making it really simple to your users is to use PHP built-in server as of PHP 5.4.0.
$ cd ~/public_html
$ php -S localhost:8000
You can test this by adding an index.php in the public_html directory and then just run the command $ php -S localhost:8000 inside public_html. Open up your browser and type localhost:8000 so you can see your index.php file.
Another important thing is that your users must have Mysql installed (or whatever DBMS you are currently using).
Source PHP documentation
To avoid installing server on every client pc you can use Virtual Machine, so you would have same environment and just copy to every pc you need.
To keep the source code up to date (when connected) use GIT or other version control system (SVN may be easier to get into).
You have to install mysql or whatever DBMS you are using at backend as well as install XAMPP or any other server to run PHP script. If you dont want to install full XAMPP you can use portable XAMPP which is just copy and paste.
You can right a script which can keep checking after specific intervals, if internet is available then synch database with live server.

Is using Xampp/Wamp necessary or just a choice?

All the people I have seen working with php, were using Wamp or Xampp. And when I spoke with them as a fellow learner, their first question was which one I use(Wamp or Xampp).
Is Xampp/Wamp Server truly necessary to use or just my choice?
I first installed apache httpd server, then months later I installed Mysql community server and again months later php.I didn't plan to use them together, but now that I need to use them together, I am confused whether I should install Xampp/Wamp or it is fine without them.
Can serious and functional development can be done without using any of them?
I don't want to realize midway that I am going into wrong direction and it is not possible.I am not asking if it is recommended for ease of use or saving time. I have no trouble in learning to configure any of them and I have done so in past with very little trouble.
I would like to have an answer saying clearly whether I HAVE to use them, or they are just a matter of choice.
If you have done all the work of installing an AMP stack on Windows already then there is absolutely no reason to install WAMPServer or XAMPP.
These 2 products just make the process of installing a working AMP stack easier, they do not add anything over and above what you have managed to do all for yourself.
So when friends ask which product you use, all you need tell then is that you use a WAMP Stack that you installed and configured yourself.
I will add a couple of things though
WAMPServer does allow you to have multiple versions of Apache,MySQL and PHP installed in a way that makes it easy to switch versions of all 3 parts of the AMP stack very easily. In a development environment, I personally find this extremely useful. It means I can mimic a clients environment in a couple of seconds and at the touch of a couple menu items.
XAMPP does come with Perl.
If you want,you can download and integrate PHP in your invironment.
But if you want everything at one place then go for Wamp or Xampp.
Simple answer for the question is "it is just a choice". Because you can install all the software separately or all in one using WAMP/XAMPP

How to set up a web server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have been asked to setup an online web server (e.g, digital ocean) and describe the steps I took. (e.g, installing and configuring private keys, firewall and web server).
And also what steps did I take to secure my setup?
I know very basic about php and HTML and this my first time setting up an online web server. My main question is that to set up an online web server I must pay money and buy space or I should use my own PC as a web server. which one is easier? I am trying to stick to the above question. Any help or reference to guide me will be appreciated.
There are a few elements to consider here, for the server, you need this
computer
operative system (windows, linux, mac, ...)
setting user access and user restrictions
setting a firewall
set remote access if needed (ssh, vnc)
For the web part of the question, you need this
web server software (apache, lighthttpd, nginx, iis, ...)
server side programming/scripting language if needed (perl, php, asp, ...)
If you can use a PC that you already have, use that one, after, you will have to mae that computer reachable from the exterior, for that, you have so give your external IP to the people that is going to use it, if you have a fixed ip, use that one, if you don't, then use something like dyndns.
Of course, if you have a router, then you have to configure that router to pass the requests to port 80 to your PC serving as web server. You can start learning about that process with this search about setting a NAT
You don't have to use a dedicated machine for this, you can also use a virtual machine on your existing system, check VirtualBox, one of the easiest to set up.
All that are just the most basic steps, some are very simple, some are more complex. Definitely you don't have to buy/rent a server, although, it may be easier that doing all the work yourself. If this is for a school/university assignment, check the conditions applied and if you can use a PC/virtual server on their machines. If this for work, hire somebody that knows how to do it and if you want to learn, stay close to that person.
Hmm paying would probably be easier but you wouldn't learn anything.
My advice would be download Debian linux and install it to a computer you don't use. Then install apache.
Debian is pretty easy to install, they supply a gui, but there's also a guide here that's very in depth.
Also apache is as easy as sudo aptitude install apache2, and your documents will need to be in /var/www to show up online. Make sure your ports are forwarded. A good guide, again, is the Debian documentation here.
As far as securing it goes, make sure ssh only accepts keys, and not passwords. Also close any ports you don't need.

Is it possible to fully simulate linux web server on windows machine with cygwin? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
This is a theoretical question and hope you won't refuse it directly.
The problem I am having is that I am working both on front-end and back-end development. Basically by day I am fron-end developer which involves a lot of different browsers, Photoshop and other tools needed for design/fron-end work. But by night I am heavy php developer.
Now this is quite a tricky situation. As a back-end developer I would really love to use linux server, same as production servers for projects, which will be much easier to synchronize. But as a front-end developer I need all the tools, that are available mostly for windows.
I have been looking long time for a solution OTHER than virtual linux machine. Finally i ran into the Cygwin. It looks promissing, but my question is, can I fully simulate linux webserver with this tool? are there any limitations?
I would appreciate any opinion, also if you know about some elegant way/tool how to achieve what I need, please share it with me.
Thank you!
EDIT:
Why I don't want to use virtual machine:
It takes too much RAM. If I run IDE, Photoshop, Virtual Machine etc. my PC has hard time to catch UP
I am looking for "seamless" solution. Something that can run quietly on my background, best as a service.
File sharing. I know it is possible to share files between PC and virtual machine but I just don't feel like it is very elegant solution
I had something more on my mind, but this is what I could come up with so far.
Basically Linux is pretty amazing, and I just cannot believe there would not be any simplier, less-robust solution to this problem than installing whole linux system.
Wish I could help more, but right from cygwins website it says "Cygwin is not: a way to run native Linux apps on Windows."
That said, it appears some people have got a lamp stack working in Cygwin and also here
So it sounds possible, but I have to re ask the question of why you would want to. Seems extraordinarily complex when you could install virtualbox and a turn key linux solution to get a real environment that is much easier to troubleshoot.
If you do get it working, I'd love to see a blog post on how you got it.
It depends what you mean by "fully simulate".
You can run an apache web server in cygwin, but it is quite difficult to set up. By a strict definition of "fully simulate" this is already quite different, the steps to set up the web server are different from a real linux machine.
Given that PHP already abstracts a lot of the underlying system away from you, you might find that there is really very little difference (for most purposes) in going down this path vs just installing wamp for your development.
Rather than install a virtual machine on your dev system you could also get a free amazon instance (for the first year) and do your web dev on that.
You can run Apache with PHP on a windows machine without any hassle at all. You do not even need Cygwin.
I run Apache+PHP and use it for development. I have not had any problems with transferring to a Linux machine. I use FTP Sync to update the Linux machine with just a click on an icon and it just updates the necessary files.

Categories