Web Development Blog

Connect to a remote Mac OSX without Apple Remote Desktop

You want to connect to a remote Mac OSX computer and you don't have Apple Remote Desktop. Mac OSX Leopard comes with a built-in screen sharing application that allows you to connect to another Mac. It is in fact a VNC client, so if you are familiar with VNC you may already have a preferred VNC client application as there are a few to choose from.  

Requirements

  • Two Mac OSX Leopard computers

Setup the built-in Screen Sharing

  1. In your remote Mac OSX Leopard turn on Screen Sharing, it can be found in System Preferences > Internet and Network >Sharing. Turn on Screen Sharing and click on the Computer Settings button and check the VNC viewers may control screen with password option and set a password. Screen Sharing is similar to logging on with remote desktop to a console session.
     

     

  2. At this point it’s a good time to consider network security. VNC is considered insecure, if you are connecting over the Internet to your Mac OSX Leopard computer, it is recommended you create a SSH tunnel for your VNC session or connect to your remote network via VPN. 
  3. If your network runs a firewall you will need to create a port forward through the firewall to the Mac OSX Leopard computer.
  4. To connect to the remote machine click on Finder then in the menu select Go > Connect to Server and enter vnc://yourserver.com:5900, in this case the :5900 part is optional, because 5900 is the default port for screen sharing.
     

     
  5. Push connect and you should after a moment be presented with the remote screen of your Mac OSX Leopard.
     

Summary

Using Screen Sharing to connect to your remote Mac OSX is easy and best of all, you don't need to find or buy any extra software. I did find however it is still substantially slower than using Apple Remote Desktop and of course you miss out on lots of good features in Apple Remote Desktop. You can also use the same Screen Share application to connect to a 3rd party server such as Vine Server.


Getting Started Debugging PHP with Zend and Eclipse on OSX

Its been quite some time since I looked at a PHP script, the first dynamic website I built was PHP and PostgresSQL and for sometime it was PHP all the way. But sometimes project requirements dictate a certain language, so later I worked with  Allaire Coldfusion, ASP and ASP.NET.

I used two debugging techniques for PHP

  • The first method is turning on error reporting which is an after the fact method of determining the problem. It can sometimes be difficult to determine the cause of the problem, as error messages often tell you exactly what is wrong not the cause.
  • The second method employed is printing out variables at points in my scripts to narrow down the point at where the error is occurring.
If you are new to web development and these methods and want to know more there is a good explanation on the debugging techniques for PHP programmers using print statements, error reporting.

I thought it would be a good time to look at some of the developments in debugging PHP. Unless you write your code perfectly first time off debugging is an important part of developing any sort of software. Often a quite time consuming part.

Not new by any stretch of imagination is a third method using breakpoints to stop the execution of your code and inspect the values of variables and the flow by stepping through line by line. Using Visual Studio and ASP.NET this is easier than tying your shoe lace.

Debugging with an Integrated Development Environment and Debugger

There are number of choices available free and commercial when it comes to a PHP IDE

  • NuSphere PhpED - Perhaps the leading PHP IDE, lots of features, but you will need to dust off your windows computer to run it. 
  • Zend Studio - Again it has plenty of features and is available for any platform I haven't tried it out yet.
  • Komodo Edit and IDE - I tried the Komodo Edit on OSX seemed slightly clunky.
  • Editplus - A basic text editor verging on IDE status, I quite like for typing out your code and quick edits, available for windows only.
  • Eclipse PHP Development Tools - A free open source development tool that provides you with the basic code editing capabilities you need to get started. Perhaps the easiest option to get you going, Zend provide a 'all in one download' that installs Apache, PHP, MySQL and Zend Server & debugger.

I installed the Eclipse PHP Development Tools for Mac OSX and proceeded to start developing my hello world application. I've used Eclipse before for some Java projects and found it good and of course its open source and free.

  1. Download and extract Eclipse PDT All-in-one, I downloaded the Mac OS X (Cocoa64) version. Eclipse will run directly from the extracted folder so move it to a sensible location.
  2. Download and install the Zend Server Community Edition. This will install Apache, PHP, MySQL and Zend debugger.
  3. Configure the Apache installation , on OSX the Zend Server go to Finder > Go > Go to Folder and enter /usr/local/zend/apache2/conf from here you can edit the Apache configuration file httpd.conf.
  4. Open terminal and type sudo pico /usr/local/zend/apache2/conf/httpd.conf and enter your password when prompted. As long as you have permission this will allow you to edit the httpd.conf file with the required root permissions.
  5. I added a virtual directory /Sites to Apache to make it more accessible. To do this at the bottom of the file enter the following, of course replace <USERNAME> with your user name.

    alias /Sites "/Users/<USERNAME>/Sites"
    <Directory "/Users/<USERNAME>/Sites">
    Options +Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

     
  6. Open Eclipse and create a project folder in your /Users/<USERNAME>/Sites such as HelloWorld  again replacing <USERNAME> with your user name.
  7. Edit your project debug configuration like so, NOTE: the Zend server by default runs on the port 10088.
     

     
  8. Create the file index.php and enter the following to create a basic class to output "Hello World"
     
    <?php 
     
    $test = new myclass(); 
    $test->hello(); 
     
    class myclass { 
         
        public $message = "Hello World"
         
        function hello() { 
             
            echo $this->message; 
        } 

     
    ?> 
     
  9. Add a breakpoint, in your index.php file, to do this double click in the gutter to the left of the line echo $this->message;
  10. Click on Run > Debug and the Eclipse perspective should change to the debug version and stop at your breakpoint.
     

     
  11. From here you are good to go, you can step through your code and inspect variables.
Good luck I hope this helps anyone getting started debugging PHP with Zend and Eclipse on OSX .  

How to use WSE 3 in Visual Studio 2008

I upgraded some projects to Visual Studio 2008, in the project I was using a WSE 3.0 web service. The project compiled fine but I found when I updated the web service I was using the proxy class that was generated did not work. The proxy class inherited from System.Web.Services.Protocols.SoapHttpClientProtocol instead of Microsoft.Web.Services3.WebServicesClientProtocol. This was quite a problem I didn't fancy having to manually recreate it each time  wanted to update the WSE 3.0 web service.

I googled for the solution and found a number of solutions that involved writing some code for an add-in. Eventually I found the perfect solution. Jinal Patel posted how to use WSE 3 in Visual Studio 2008.

Here is a summary of Jinal's solution, check his site for the original solution.

  1. Download and install WSE 3.0 but if you are reading this its probably installed. 
  2. Locate the Visual Studio 2005 add-in at following location C:Documents and SettingsAll UsersApplication DataMicrosoftMSEnvSharedAddins
  3. At that location you find the file “WSESettingsVS3.Addin”.
  4. Open file in locate the section <Version>8.0</Version>  and change it to <Version>9.0</Version> and save
  5. Open the Visual Studio menu and select Tools –> Options –> Environments 
  6. If its not already listed add %ALLUSERSDOCUMENTS%MicrosoftMSEnvSharedAddins
  7. Restart Visual Studio.

The solution didn't work straight off I had to make one more change. A second post by Jason Young, How to use WSE 3 in Visual Studio 2008 shows a second setting that was required. The only part of the post I followed was the addition of the xml below to the devenv.exe.config file.

<system.web>  
    <webServices>  
        <soapExtensionImporterTypes>  
            <add type="Microsoft.Web.Services3.Description.WseExtensionImporter,  
               Microsoft.Web.Services3, Version=3.0.0.0,  
               Culture=neutralPublicKeyToken=31bf3856ad364e35/>  
        </soapExtensionImporterTypes>  
    </webServices> 
</system.web> 

That's it, I restarted Visual Studio and updated the web service and the WSE 3.0 proxy class and methods were generated.