How to edit source code in local computer and server simultaneously - web-deployment

I am a new web developer. I am using XAMPP and Dreamweaver CS6. I want to edit and debug my source code on my local computer. Then I want to commit that edit to my web server (shared or vps). Right now I edit files on local computer and then I upload that file to server.
Can anyone suggest any other options.
Thank you in advance.

I suppose you could achieve this in many ways.
For example you can use deployment tools (like Jenkins) and then configure it to hook your commits. In order to do this you need first to install Git in your system (I'm not sure but maybe you can even find some Git plugins for Dreamweaver so that you could work with Git directly from Dreamweaver; if not don't worry there are plenty of Git clients that help to facilitate use of Git, SourceTree is one of them)
If you feel like you have difficulty in configuring Jenkins to hook your commits I'd suggest you to have a look at this answer.

I haven't used Dreamweaver in forever but you can upload on saving which you set in the Site Definition. Go to the Remote definition that you setup and click on the Advanced tab. You can set DW to automatically upload on save there. It's generally not best practice but it's an option.

Related

How to push small local changes to remote server with Git and Wordpress?

I'm new into Git and I'm working with Wordpress themes.
I was always using FTP client to push every small change into my remote server... I mean sometimes it was just one line of code to check the change of CSS. It was easy and nice but there will be always problem with reverting changes and since I'm learning Git, I want to change it.
I've found two ways to do it:
git-ftp
i've tried to connect my local respository with GitHub and my intention was to automatic pull changes into my remote server from GitHub (it's not working yet, i need to configure it better)
BUT, do I have to commit every single small change? Because I cant just save file and check changes with Browsersync on second monitor, I will have to commit so many times. Also which way will be better for me - maybe there are another, better ways?
I really want to improve my performance, but it looks like that's not easy or I'm doing something wrong? I know about existence things like WP-CLI, webpack, gulp but often I'm creating small websites and probably I will spend more time on configurating those things than create theme. Also I thought about working on localhost, but I really think that I'm complicating things and my job.
Really sorry if it's wrong section, but I'm new on stackoverflow - hey! I will be really thankful if you can help me, because I think that i need knowledge of someone experienced.
I'm not sur to be helpful but I'll try :
First, even for a small project, I always prefer to install a local environment for testing. It avoid risks on your remote server !
You can take a look here : https://make.wordpress.org/core/handbook/tutorials/installing-a-local-server/
Then, if you have an SSH access to your server, may be you can try to configure it to push directly from your local environment to your remote server. Here is a simple tutorial : https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
It depends on what remote system or vps you are using.
It could be from GCP, AWS, DIGITAL OCEAN, or WP itself.
It looks like that you are using the wordpress hosting your website.
If so, you might use wp cli to login the server.
①As for the frequent testing and updating, it is a good idea to copy the remote project to your localhost. Run your web app using wampserver. And create a new repository in the github and connect it with your local folder.
Then you could use git to version control your codes, do pull and push, stash or whatever.
And after testing, you could upload the specific files or folder to the remote server via ftp or sftp periodically.
②Another way is to install the git bash or git software in your server side.
It depends on the OS you are using. If it is a win or linux.
$ add-apt-repository ppa:git-core/ppa
$ apt update; apt install git
and create new user, add it into the sudo group
create a repository in your server side and link it to the github remote repository.
I am not sure whether the second way would work.
I recommend you try the first method.
Hope this could help. Happy coding.

Where do I place my own code whilst using Vagrant+Chef+Wordpress (VCCW) repository cloned from GitHub?

I ran across the VCCW project and despite my unfamiliarity with Vagrant and Chef, decided to give a try. I followed their instructions and obtained the VCCW project itself by installing the GitHub Windows program and cloning the VCCW GitHub master repository. I should also mention that I have very little experience with Git.
Anyway, now I have VCCW Wordpress running on my machine, but I've no clue what to do from here. I wanted to set up a better and more formal Wordpress development environment so I could write my plugin and modify a theme, but I don't know where I should do that. I know where the actual Wordpress installation resides on my file system, so I suppose it would be easy to work from there, but I don't know how (if at all) that interplays with the Vagrant workflow - ie, when it comes time to use Vagrant to deploy my site, will my changes to the "www" folder (which was created by vagrant up) be captured? Somehow I doubt this. Just looking for any help as to how all these fancy new tools work with each other and what a humble PHP developer like myself should do to get started.
Edit: One more question: which IDE, if any, can I use in conjunction with this arrangement? Create a new project from existing sources, and let it pollute my deployment folder with project files?
From the Vagrantfile, it looks like you should look in ./www/wordpress after provisioning.
VCCW includes deployment tool WordMove.
You can deploy WordPress into your server from vccw if you set Movefile.
Movefile will be created automatically after provisioning, so you should add your server configuration in Movefile.
http://vccw.cc/#h2-10
https://github.com/welaika/wordmove

How to develop using GIT on database driven website project?

I like to use a simple Git workflow for static web sites but I build Joomla and Wordpress sites a semi-regular basis too. However I am at a loss as to how to use Git with with database driven site development.
For a static site I would 'Push' to dev.websitename.com, then push to www.websitename.com once the dev site checks out. How would I mimic that process with database driven site like wordpress or joomla.
Thanks in advance for you insight!
You can definitely use Git with your website code, such as changes to your WordPress theme/plugin, exactly as you would if you are developing a static website.
However, you wouldn't use it for your database. Git provides version control for code, while WordPress and Joomla already manage content stored in the database. Plus, Git wouldn't understand a database, so it wouldn't have any advantage over a periodic backup, which you should already be doing. Take a look at running a dev copy of your site for how to download your database directly from your server.
By the way, if you use Git with WordPress/Joomla, you should add e.g. cache, logs, tmp to .gitignore. There are also lots of tutorials out there--try searching e.g. http://google.com/search?q=wordpress+git.
In addition Chris, you may want to embark on your Git workflow without the handy script approach (at least initially). The script approach and using Git hooks can sure seem sexy (well, because they are) and handy too, but initially why not go with a more manual cmd line approach, which will also help you familiarize yourself with Git.
Once you've got your repo setup (GitHub, Bitbucket, somewhere else) and you've pushed your latest to it and are ready to deploy to production or staging, just login to your host and from wherever you've initialized the git repo (site root, example: /site) just do a:
git pull origin master
This will fetch and merge your code. Good idea to test this on a dev/staging environment and if the merge goes well then do it in production.

Visual SVN Server: Guide on Pre/Post Commit Hooks

This may be best as a wiki, given comments on here:
Share common / useful SVN pre-commit hooks
I'm using Visual SVN 2.1.7 on a Windows 7 machine. We have developers committing from various countries and we can manage the code changes by running local copies of the changes and then uploading manually via ftp to the server for each website that's being worked on.
This is an incredibly time consuming process, but less time-consuming than fixing bugs on live sites, so it's a step in the right direction.
On the Visual SVN website it makes a mention of post-commit and pre-commit hooks but fails to show where that can be accessed, even though it mentions there is a GUI. There's no sign of a GUI or even an option in the installed version, so I can't locate, firstly, where to access it.
Assuming it can be done via scripting, I have googled and come to SO to look for some guidance on where it might be and how it might be done, but it seems to be a lot more complicated than I'd hoped.
Does anyone have any experience or guidance, including sample scripts, for how to perform the following tasks on Windows (without perl installed)?
a) Create a pre-commit command/file and attach its execution to a repository/commits to it
b) Create a post-commit command/file and attach its execution to a repository/commits to it
and in my case, one specific task:
c) How to have a local Visual SVN installation on a PC that can send committed files to remote CentOS shared hosted server (not VPS/Dedi or Cloud hosted and SVN can't be installed on those machines)
It's a great piece of software but it seems like the barrier is quite high to being efficient with it because it's unclear what questions you need to ask or where to look. Hopefully, you can help provide a better starting point for those stuck in the same way.
Thanks :)
Access to hooks:
1.Start VisualSVN Server Manager
2.Open Properties for your repository
3.Select Hooks tab
4.Edit the needed hook
Hooks are convention rather than configuration based. You don't have to "hook" them up. Create a pre-commit hook and you have a hook running before commits. Create a post-commit hook and you have a hook that runs after a commit.
Here are the steps you can do in your post-commit script for what you need:
You get the repo path and revision commited as arguments to the post-commit hook, so use something like repo=%1 and rev=%2 to get these values.
One way to copy files after commit would be to have a working copy on your server, issue an svn update on this working copy after your commit in your post-commit hook and then copy over the files. You can selectively copy over files by getting the files that changed using svnlook changed. svnlook needs a revision and use the rev variable that you set earlier.
The script itself can be in any language.

Duplicate a Drupal installation from one server to another

I have been developing a Drupal 6 site on my PC using XAMPP. I'm done now, and everything looks peachy.
Problem is, I need to put all my content (including custom modules and themes) up onto a staging server which only has a fresh Drupal 6 install on it. I can't imagine having to set up all my custom content types and whatnot all over again on the staging server.
So I ask, how does one go about doing what I need to do? Which is essentially duplicating my Drupal install from my PC, to the staging server.
The staging server is running Linux, and I develop on a Windows PC, if that helps.
Thanks in advance.
Copy up all the files from development to live, and mysqldump your database and run that on the live server. Then all you have to do is change the settings.php file to point at the right database, if for some reason 'localhost' is not also your mysql database.
The quickest solution is probably the backup_migrate module. It is only a tool to copy your database. You could also use phpmyadmin or similar instead if you wanted. The backup_migrate module do have some good defaults settings as to which tables to skip (like cache tables). All the settings etc. that is not defined in code is stored in your db. So you only need to copy the db to be set. You can choose to exclude some tables, like the node or user table if you don't want to bring over your test data.
If you don't use subversion, then you gotta manually copy the files (rsync, scp, whatever) and the db (mysqldump).
what we usually do is have a hierarchy of independent subversion repos as follows:
core
sites/all/modules/contributed
sites/all/modules/custom
sites/all/themes/ (we develop our own and don't use contributed themes)
sites/all/libraries
then we use the svn:externals properties so that if you check out "core" you get every associated repo.
we got about 2 main developers with 4 other guys that may also contribute code to the site. each have their own local dev environment and we all got a common sandbox - where we make sure the stuff we wrote doesn't break someone else's module (it has happened before!).
we use svn commit hooks to update the beta/staging/sandbox site upon commit.
with all that setup, [re]deploying a site is a simple matter of going to the proper folder and issuing a "svn co http://repolocation/reponame ." and then updating the DB.
two last things to consider:
we are moving from svn to git
the features module will allow you to save changes you make to your own modules (views, content types, etc) and package all that into a deployable module so you don't have to duplicate your efforts. we are also looking into using this for ourselves.
I hope this helps you.
I second using backup_migrate. It's great.
When I'm installing a fresh site from development to production, I:
backup the site using backup_migrate module
copy all the files up to the server
edit the sites/default/settings.php to have the right database path and account info
do an import of the last backup_migrate dump (usually using mysql < backupfilename.sql, unless I already have drupal setup and have backup_migrate installed, then I use the GUI
But take a look here for the official version:
http://drupal.org/node/776864
Now, you didn't ask, but when the site is live and users are contributing content, moving future development versions of your site from development/staging to production without blowing away live content is a whole different problem, and one that Drupal doesn't have a good answer for...
Andy-

Resources