Here's how things look at the Linux/Mac meet and greet:
Mac, may I introduce Linux.
Apple Filing Protocol, meet Netatalk.
Bonjour, this is Avahi.
They are, in short, Apple services and their open source counterparts.
My process of setting up an HTPC did not involve purchasing a mini mac, rather I repurposed my trusty and well-worn Cube PC as a newly reformatted 500GB Ubuntu 11.04 file server.
For seamless file serving, the UCube now utilizes Avahi and Netatalk to provide intersection to my LAN. When you gather crumbs of info to make your own similar setup, I recommend you use a succinct, updated guide such as Sidi Kahawa's. Though hundreds of responses exist on the older stalwart of this process, most of them have been fully addressed. It's close to turnkey at this point.
Monday, August 1, 2011
Friday, March 11, 2011
SVN on Eclipse using JavaHL
If you're finding that Subversion is not working with Eclipse due to an error such as:
After you install the binaries, you should be able to verify that JavaHL is working by visiting Eclipse>Preferences>Team>SVN, on the drop-down for SVN interface client.
unable to load default svn clientVisit Collabnet and download the latest Universal Subversion Binaries. I searched for a direct link to get software using the Eclipse software utility, but found nothing as useful as the repository on Collabnet. Unfortunately you have to register first, but it's a quick form.
After you install the binaries, you should be able to verify that JavaHL is working by visiting Eclipse>Preferences>Team>SVN, on the drop-down for SVN interface client.
Tuesday, March 1, 2011
References and Cloning examples
A very interesting example of the subtleties of cloning and referencing variables. Particularly noteworthy is the manner in which the references can be exploited to show ambiguous behavior. See the following example from php.net.
Object cloning with php5
Object cloning with php5
Friday, February 25, 2011
Pointers in Python resemble variable assignments in PHP5
I encountered the PHP5 clone operator '=&' and a very good illustration of its use. Incidentally, PHP5 variable assignment resembles the use of pointers in Python.
In short, a variable assignment in PHP is a reference to the assignment object. If an object ( $pointer = object ) is reassigned ( object = 'foo'; ), the pointer will reference the OLD object ( $pointer = object ). If however you clone the object ( $clone =& object), when the object is reassigned, ( object = 'foo' ), clone will change as well ( $clone = 'foo' ).
Cloning, then, is making the variable operand synonymous with its counterpart, rather than a reference to the counterpart. There are some particularly enlightening examples of 'clone' aka '=&' on php.net.
In short, a variable assignment in PHP is a reference to the assignment object. If an object ( $pointer = object ) is reassigned ( object = 'foo'; ), the pointer will reference the OLD object ( $pointer = object ). If however you clone the object ( $clone =& object), when the object is reassigned, ( object = 'foo' ), clone will change as well ( $clone = 'foo' ).
Cloning, then, is making the variable operand synonymous with its counterpart, rather than a reference to the counterpart. There are some particularly enlightening examples of 'clone' aka '=&' on php.net.
Integrating MAMP PHP and Eclipse PDT for CakePHP Debugging
There are a few steps necessary to get Eclipse PDT, MAMP, and a CakePHP app synchronized for debugging. Summarily, after adding the Zend Debugger to Eclipse, the php initialization file in MAMP must be modified so it can respond to Eclipse. MAMP is not pre-configured for use with Zend Debugger, so you must edit the php.ini file for MAMP. Find the location of this file in the phpinfo tab of MAMP (near the bottom in the screenshot):
Open this in a text editor such as vim, and you will find this info near the bottom (italicized configuration info added at this step):
Now that you have detailed the location of ZendDebugger.so, you need to actually add a copy of the file in that location. Go ahead and put a copy of ZendDebugger.co (which either you have already downloaded into your Eclipse plugin filesystem, or you can download it as part of the Zend Debugger package ) into this directory. Incidentally, ZendDebugger.co can be where ever you like, so long as the path in php.ini resolves to it.
Comment out any references to zend in php.ini, other than the ones in italics above. In addition, comment out xdebug references if they are not already commented out.
Finally, restart MAMP and look for this confirmation in your restarted phpinfo():
If debugging in Eclipse succeeds, the debugger will halt at the first instruction. Be sure to step through a few instructions (F5) to ensure it is working properly. Here is a thoughtful and concise external resource to follow as a further guideline.
Incidentally, CakePHP:
As stated above, this guide will help you get debugging to work with CakePHP. That part of the process entails a further step. Once you are in Eclipse debugging a CakePHP project, you may find the debugger prompts you to resolve the location of core php files as it steps through them. This will happen, for instance, when you debug CakePHP apps you have created by using the cake bake CLI prompt.
To resolve these prompts, simply make sure the following conditions are met:
Open this in a text editor such as vim, and you will find this info near the bottom (italicized configuration info added at this step):
[xdebug]
;zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
[Zend]
zend_extension="/Applications/MAMP/Library/modules/zend/ZendDebugger.so"
zend_debugger.allow_hosts=127.0.0.1
; zend_debugger.expose_remotely=always
Now that you have detailed the location of ZendDebugger.so, you need to actually add a copy of the file in that location. Go ahead and put a copy of ZendDebugger.co (which either you have already downloaded into your Eclipse plugin filesystem, or you can download it as part of the Zend Debugger package ) into this directory. Incidentally, ZendDebugger.co can be where ever you like, so long as the path in php.ini resolves to it.
Comment out any references to zend in php.ini, other than the ones in italics above. In addition, comment out xdebug references if they are not already commented out.
Finally, restart MAMP and look for this confirmation in your restarted phpinfo():
If debugging in Eclipse succeeds, the debugger will halt at the first instruction. Be sure to step through a few instructions (F5) to ensure it is working properly. Here is a thoughtful and concise external resource to follow as a further guideline.
Incidentally, CakePHP:
As stated above, this guide will help you get debugging to work with CakePHP. That part of the process entails a further step. Once you are in Eclipse debugging a CakePHP project, you may find the debugger prompts you to resolve the location of core php files as it steps through them. This will happen, for instance, when you debug CakePHP apps you have created by using the cake bake CLI prompt.
To resolve these prompts, simply make sure the following conditions are met:
- Your CakePHP app is in a project folder in Eclipse ( it has to be! )
- Your CakePHP core library is in a project folder in Eclipse. This way, the files are available to the IDE so Eclipse can step through them in a debug process.
Labels:
cakephp,
debugging,
eclipse builder,
MAMP,
php5
Wednesday, February 23, 2011
CakePHP / Eclipse Project Integration
Creating projects in Eclipse that work with CakeBake is a multi-step process consisting of:
- Initiate a new PHP Project in Eclipse, e.g. php_project
- enable JavaScript code checkbox
- Create your initial database so you can input the settings in step 3.
- In Terminal, run cake bake /path/to/php_project
- add database settings if you have them
- heed this info if you are using MAMP and the database does not resolve
- Use eGit or SVN in Eclipse to bring in any plugins you may need
- Configure Run > External Tools > External Tools Configurations to run further operation such as
- cake bake model
- cake bake view
- cake bake controller
- You can also simply use Terminal to invoke interactive cake commands. Refresh Eclipse to see subsequent filesystem changes.
Tuesday, February 22, 2011
Authorization in CakePHP
From the Cake Book 1.3:
This single line will implicitly password-protect your entire site. For explicit, group-or-user-based password protection, add to Auth the ACL:
User authentication systems are a common part of many web applications. In CakePHP there are several systems for authenticating users, each of which provides different options. At its core the authentication component will check to see if a user has an account with a site. If they do, the component will give access to that user to the complete site.In short, authentication is a turnkey option in CakePHP. All you need to do to enable it is open and edit your app controller at site_name/app/app_controller.php, adding:
var $components = array('Auth');
This single line will implicitly password-protect your entire site. For explicit, group-or-user-based password protection, add to Auth the ACL:
This component can be combined with the ACL (access control lists) component to create more complex levels of access within a site. The ACL Component, for example, could allow you to grant one user access to public site areas, while granting another user access to protected administrative portions of the site.Finally, don't forget to run by the fridge for a cold can of PBR, 'cause you're going to want to celebrate the ease of this authentication framework.
CakePHP's AuthComponent can be used to create such a system easily and quickly.
Subscribe to:
Posts (Atom)