Sublime Forum

Emulating the zend build

#1

Hi,

I have been using SublimeText2 on my Mac for about 6 months and love it. However I am now in a job where I am working with Zend and I can’t get ST2 to emulate one of the tasks Zend Studio does.

In Zend Studio when I save a file it gets rsynced to a staging server using the inbuildt “Builders”. I am sure ST2 can handle this but I am not sure how I can get it working.

This is what I need ST2 to do kb.zend.com/index.php?View=entry&EntryID=414

Any ideas?

Thanks in Advance,

Craig

0 Likes

#2

I use something similar to sync modified files to an eclipse workspace. This is a stripped down version of the plugin i use. This would be executed after every save, even if the file you saved is not from the project! You could also make a build system. The authentication is not included in this sample.

[code]import sublime, sublime_plugin

class DeployOnSaveCommand(sublime_plugin.EventListener):
def on_post_save(self, view):

import subprocess
# The shell script to deploy the project to the server
syncProject = """rsync --recursive --times --perms --exclude ".*" /path/to/project/ /path/to/server/"""
# execute the shell scripts
subprocess.call([syncProject],shell=True)

sublime.status_message("Project deployed")
[/code]
0 Likes

#3

Hi, and thanks for the reply.

I am not sure how I get it to work on save, the arguments I need are:

-vcrz
–delete-after
–exclude-from=.rsync-exclude # <-- This is a list of file to exclude
.
@10.0.0.248:projects/<project_name>

I am not even sure if the code is running, how do I check, I do not get the Project deployed message in the console.

Do you know how I can get this to run. I can’t figure it out.

Thanks again.

0 Likes

#4

Under your “Packages” Directory (Preferences > Browse Packages) create a Directory and give it the plugin name. Inside of it create a .py file and give it the plugin name. This code should than print Hello to your console on save:

[code]import sublime, sublime_plugin

class HelloOnSaveCommand(sublime_plugin.EventListener):
def on_post_save(self, view):
print(“Hello”)[/code]

Your rsync statement has to be the same as you would use in the Terminal. You can test it there first.

0 Likes