Setting up a (web) development environment - php

I would like to know how I can improve my development environment.
At the moment:
I'm using Netbeans as my IDE.
My local Dev server runs on a RHEL5 VirtualMachine similar to my production server.
My Netbeans project is editing the VM files via ssh (I have mounted the server as a local drive)
But:
It's slow
Files can disapear ( netbeans delete them ? )
I can't use git on it because it's slow.
The idea would be to be able to have a shared filesytem between the guest os and the host os.

Your setup sounds ok. You might need to give your virtual machine more resources however if your experiencing speed problems. That or move your server to a separate physical machine.

You may try a setup for files the other way around. Keep your files an the host machine in the shared folder. Than on your VM create a symbolic link from your htdocs folder to that shared folder. In this case developing should be very fast but only running the website on your VM might be slower.
EDIT: My setup is the following:
I got a XAMPP running on Windows 7 for development
I got a SVN repository on the webserver the production system is runnig
In a separate subdomain on my webserver I have a test system running
So basically I develop under Windows, I test on the same machine that runs my production system. We even got Macs for developing as well. I never had any issues developing under Windows and running the page on a openSUSE system (beside case-sensitive file names). Using the exact same machine for the test server is a good idea as it has the same limitations as the production server. So I think having three system DEVELOPMENT, TEST, PRODUCTION is the best you can get. But if it is only for some smaller projects your setup look quite good.

I find XAMPP sufficient for nearly all development locally :)
http://www.apachefriends.org/en/xampp.html

It depends on the type Virtual Machine you're running. For example Vmware is able to share a specific folder between the guest and the host OS

if you're using a mac, I'd recommend : http://www.mybringback.com/bringers/14509/git-local-and-shared-server-development-environment-with-ssh-setup/
which uses a local mamp/git/ and live server.
You could probably follow along with windows, but it's been awhile since I used it, so I'm 100%
best of luck

Related

How can I use interface of PHP that is installed on the linux operating system in window operation system?

I want to use the Windows operating system to develop my PHP code, but PHP is installed on the Linux operating system. My PHP code runs on the Linux operating system, so I want to use a Linux provided interface of PHP. How do I do this?
If I understand correctly, you want write your code on Windows, but run it on Linux. In this case you can use Vagrant or Docker. I am not experienced with docker, but I can provide some information about Vagrant:
From Vagrant docs:
Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the "works on my machine" excuse a relic of the past.
It allows you to simulate real server inside your Windows environment, by running virtual machine. You can setup shared folders, so you can do your code writing inside your Windows, and run it inside virtual machine, which could be Linux environment with installed LAMP stack.
To learn more about it, there is plenty of articles on the internet, for example:
https://www.sitepoint.com/getting-started-vagrant-windows/
You can also use puphpet to easily setup configuration for your virtual machine.
By default, shared folders in vagrant are very slow, especially in Windows, to make it faster you can use NFS file system. There is a plugin for Windows called winnfsd.

Complicated setup with Git, Laravel, PHPStorm and VPS

What I have so far:
Two VirtualBox LAMP machines (separate locations) where I connect my two Windows development machines via SFTP, to write code using PHPStorm.
One VPS machine where I deploy my code written for a project in Laravel.
What I am trying to achieve:
Fast and easy code deployment, as in: write the code in Windows via PHPStorm, test it on the LAMP machine, deploy to VPS if necessary.
The problem is that I need to use some php artisan commands on LAMP machines to get some code generated. This means that I always have to synchronize PHPStorm with LAMP files tree in order to see the changes. Then, I need to also sync the other dev (LAMP) machine and the other PHPStorm running on Windows machine number 2. I know that this can be done via Git.
So everytime I use the command line to generate code, I need to sync 4 machines (excluding the deployment server).
Later, if I add another pair of Windows/LAMP dev machines, the complexity grows.
Back in the days of Dreamweaver, I could write code directly on the deployment server. Not the greatest idea, but it was way much simpler and faster, and that's what I need now.
Any ideas on how can I simplify this?
Switching to WAMP so I can have files in sync with PHPStorm (because all is locally) is not OK because... Windows and PHP libraries issues :)
Also, switching to Dreamweaver is not OK either.
What other options do I have?
Thanks!
LE: on the side, I am also thinking if a NAS can be helpful for this type of problem.
LLE: is Linux Desktop + PHPStorm the only straight solution?
No matter the protocols
You can put your code outside of the guest machine and configure the guest machine to mount the code (mount a folder from the host inside the guest).
Apache will run slower because it will use the mounted remote-folder but PHPStorm will run at its maximum speed.
Taking protocols into consideration
Try using SSHFS on windows.
I use SSHFS for remote development from my Linux host machine to headless vagrant boxes (and/or to remote development servers / staging servers).
It's much faster than SAMBA (the windows SMB protocol) and oddly faster than NFS even though SSH uses encryption.
Coleages using Windows+SMB often leave their computers for 30 min while PHPStorm is indexing and git branch changes on the dev machine go unnoticed for minutes at a time.
Indexing over SSHFS usually takes less than 5 min on a Symfony2 project. Branch changes are detected in less than 15s.
Using Linux (shameless plug)
Linux is nice, and it's free, and it works out of the box (Ubuntu) -- including pesky USB-Modems which would normally require an install on windows.
You already know how to handle a Linux CLI the learning curve is already halfway crossed.
Auto-updates don't rule your life, they're not the king of you!
All the applications you need are part of the software repositories you don't need to look for anything, download 40+ executables and attempt to install them just to be welcomed by an error "invalid architecture", "windows version not supported", ".NET framework version too old", "DirectX version too new (wtf?)", "your cousin is a software pirate".
Dependency management is a concept Linux never fully solved -- but at least the bloody tried and in 90% of consumer use-cases it fits the bill. Windows is still eating glue at the back of the class.
How I solved the problem:
I have an extra Mac, on which I installed everything for my PHP ecosystem, including the IDE, so everything is local. That's the dev machine. Then I manually copy the code to the VPS when needed. Another solution was to install Ubuntu Desktop (or similar) on dual boot with Windows and use it as a local dev environment.
Much faster development / deployment :)

VirtualBox Ubuntu LAMP Stack development, with SVN and CruiseControl/phpUnderControl?

I've got a Windows 7 machine upon which I do both PHP/MySql Dev, and .NET/C#/Sql Server coding. Due to a recent re-install, I thought it might be an ideal time to try and keep my machine a bit cleaner rather than install both Apache and IIS, etc.
I installed VirtualBox, with Ubuntu 10.04 as the guest OS, with the plan to move my PHP development from my old Windows/Apache/MySql platform onto this virtual image. In addition to this, I want to add CruiseControl/phpUnderControl to my PHP development process.
So far I've got Ubuntu 10.04 installed with a LAMP stack, plus Netbeans for PHP, MySQL Workbench, etc, which is effectively the same as my old Windows dev set up, but I've now also installed SVN and CruiseControl (I've not installed phpUnderControl yet, but that is the next step).
My question is, can I use this virtual image as both my "local" development environment and as a build server, so that I don't need to clutter my native windows machine with MySql/PHP related software (meaning I can keep it nice and clean for .NET development)?
I imagine I'd need the virtual webserver to be able to serve both a "local" dev version of any given project I'm working on, as well as a staging version, which would build using cruisecontrol/svn commits?
Or should I separate my dev and build servers, perhaps keep the local development in windows, and only use the virtual image for the build server? or perhaps have two separate virtual machines for different purposes?
I'd appreciate some advice on the best way to set this up. One of the projects I want to work on is quite complex so I want to make sure I get this up in the right way before I start the project, so that I can ensure the project is well maintained with versioning, unit tests and continuous integration, should I ever need to involve other developers on the project.
If you are looking to keep your Windows box clean of MySQL/PHP tools then I'd strongly recommend the two VM approach. One desktop linux distribution for development with LAMP etc on it for the quick code/debug turnaround and one that mirrors your real server install (with the addition of svn etc) for your test builds.
This gives you huge benefits for both having a nice dev environment and more importantly having a test server that will reflect operation of your code on the live server. This way you can keep your dev environment VM up to date with the latest updates for the distribution (kernel, tools, etc) and hold the build VM at whatever application versions are on the live machine. This takes a lot of the guesswork out of "is it the new version of library X or my code?".
If you want to go slightly overkill you'd actually want 3. One for dev, one for SVN/continuous integration and one that exactly mirrors your server so you can test deployment/system configuration.
If you are considering having your VM for dev why not set it up exactly as you would setup your staging/production environment?
Furthermore you can setup your VM to host the code repository, and the web server, and then connect your tools that are local to your host machine (Windows). That way you can develop on your Windows box, connected to the VM.
This gives you the ability to do everything in your local environment while simulating the server environment in your VM.
VirtualBox does networking really well too, and you should be able to make your Windows host connect via the network to the server as if it were really another node on the network.

Developing on both Windows & Linux machines simultaneously

Sorry for the bad title (couldn't think of a better way to describe it)
I have a windows machine which I do development on. However, I have a new project which needs to interact with a linux system (executing linux commands etc.).
So, obviously I can't do development on my windows machine..and I don't wish to code on the dev machine, svn commit and then svn update it on the linux machine.
Is there a way where any changes I make on my dev machine will be quickly mirrored to the linux machine? SVN is not a very quick alternative and of course some changes will be very minor.
Any ideas? A network share I guess....but that's not very pretty (bit slow too).
As fellow developers I would like to know if you've been in a similar situation and how you've resolved it.
On a furthernote, I can't just install Ubuntu as my development machine and mirror the commands, applications etc. from the linux machine because it's a cluster 'master' machine and so therefore it has quite a special configuration.
Thanks guys!
EDIT: I've also thought about having web services on the linux machine and then just calling them from code thus seperating platform development dependency. What do you think about that too? thanks
Edit your files on the Linux machine, using Samba to expose them to Windows file-sharing.
(Alternatively via SFTP, but Windows software to mount SFTP as a filesystem isn't free.)
Have you considered using an XServer on your Windows box? You should be able to fire up a desktop session on the Linux box and have it display on your Windows machine.
Depending on how Linux-savvy you are, you may be able to get away with simply using SSH to get a terminal window, then editing files with vi or emacs. If you're working with PHP, I assume that you'll be able to see the results with your regular browser. I've done this a lot, and while it's not a full-on IDE, it's certainly workable.
You can developp your app in Windows and test it throug cygwin ;)

Where do you keep your web development environment, in your workstation or on a server?

In several years I am using my workstation as development environment. I think that most of web developers use their workstation for running their servers, Apache, Tomcat, Mongrel etc. I have been working in a company that have a Unix development server in another city, with the document root folder share with samba. I am still developing on my Windows PC because to use IDE like Eclipse PDT and RubyMine requires a fast access to the file system and because I want to try things on my own without bothering with helpdesk tickets and stuff like that. I prefer to run my tools, install/uninstall software easily.
The main problem is that I am forced to use Windows and I cannot develop on a simialr environment to Unix. For instance on production we have Passenger, in Windows Passenger cannot be used and since I have a shared environment, PHP/Rails, in development I have Rails URLs with http://localhost:3000/ and for PHP just http://localhost, on the production I just have http://domain.com/apps for Rails and http://domain.com/
So do you run your developemnt server in your workstation or on a remote server?
I would like to have a confirmation that my practice is the most adopted. Thanks.
A VM on my workstation (which has the advantage that it goes anywhere my workstation goes and I don't need to worry about bandwidth when I'm at a remote site)
I develop on my workstation, then generally publish to a staging server that mimics the live server for testing prior to publishing on the live site. When there is no staging server, that step is omitted.
I work on Linux, so don't have the problem as my servers are a mixture of RedHat, Centos and Ubuntu.
You could create a virtual machine on your machine, e.g. with VMWare of VirtualBox, that mimics your remote server. That way you'd have a non-Windows environment locally to develop on.
I do the same, I have a development server locally to have immediate access to any changes made. Whenever I can, I build a staging process on the production web server as well for the thorough testing.
If you are interested in running a Linux webserver locally (either in a box or a VM), check out this question: Pre-installed Linux for Web Developers?
I develop on a Windows machine, with Apache. When I'm happy with my changes, I push them to a test server (FreeBSD, Apache) for the client's feedback, and then when they're happy, push the changes to the production server (Debian, Apache).
Other than funny stuff like case sensitivity differences between the OSes (table names in MySQL, in particular), I haven't had any platform-based troubles.
Pretty much the only trouble I had was the initial setup, figuring out which PHP modules I needed to install on my test server. My production server's setup's out of my control.
My rule is: work locally and integrate continuously.
But TBH It really depends on the project I'm working on and on the dev environment.
In general I'd rather having the whole environment on my box for many reasons:
I'm able to reproduce integration
I'm able to reproduce issues
I can work from home or without network
BTW There were projects in which I couldn't have it on my box just because the database was so huge, or the authentication system was built by another department and I could build / deploy it on my own...
I like coding on my laptop. Since I am only web developing I like being able to be portable and code from lots of different locations because I am travelling.
Being able to then do git push or svn checkouts means that I can sync any changes with my main repository and then ensure that my main development platform on a server in the datacenter is pretty quickly up to date.
If I wasn't moving around all the time, I would use my workstation for sure.
The answer depends a lot if you're working alone or on team, and the method used to share and transfer files (Subversion, Git, SMB, FTP, ...)
In the past we used to have a shared local developement server (Debian/apache), access files via windows shares (samba), and publication to remote (pre)production servers with FTP. But, that was dreamweaver time and we had a lot of issues working together on same project. The worst case was sharing work with remote teams, painfull version management accross FTP clients.
Now, we tend to use apache on windows (wampserver) ans SVN to share and publish files. It appear to complexify the thing when working alone, but for teamwork it has no comparison with the old way of working.
The issues with php/mysql on windows are known :
- less stability and responsiveness
- Paths must be written unix-way to avoid troubles switching to linux servers (C:/dir/file.php instead of C:\dir\file.php)
- You must pay attention to mysql table names and filenames case, because if an error in case happens it won't throw an error on windows. You get the slap when you switch to production server
- Command line tools / Apache or PHP extensions that are inexistant in windows world
We work sometimes with people using Macs ou linux workstation to get rid of theses problems.
If your developement process requires Passenger on the developement station, I think you'd better use a linux workstation or run a lightweight apache server inside a VM.
For us its all SVN. A branch for developer version, where all the developers are supposed to check in the files before they leave for the day. A branch for build version, the final running or buildable or deployable one will be located here. Then there is the stage system that is used for testing and demo. The copy on the stage will always be from the build branch.
Locally. Fortunately Visual Studio makes this pretty simple.
When I get to a state I am comfortable with, I publish to a beta server, then if we like it there in testing it pushes live.
Ken

Categories