Background I’ve set up my VirtualBox to access my localhost (OSX) by following instructions similar to this post, using NAT. Everything was great until I started testing the staging site on the net (not my localhost). Most things worked fine, but uploading larger images would just fail in IE. Uploads worked fine on the localhost,… Read more »
Posts Categorized: Apple
MVC for Appcelerator Titanium (understanding Tweetanium)
Tweetianium builds it’s own namespace that it operates under rather than calling code that looks like the following to open up a new window. Ti.UI.createWindow({url:’somefile.js’, importantdata: mydata }); This essentially uses different files to open new windows, it’s managable to point, but I had trouble with not having some sort of global variables I could… Read more »
A simple framework for zend js integration through Ajax that can be used for element
Upgrading to OS X Lion [SOLVED Chrome issue ]
I took the plunge on Monday and upgraded to Lion. I know better than to do an OS upgrade while I have a mountain of work on my plate, but oh well.
The upgrade itself was the easiest ever. Just buy it, download it, then it takes about 30 minutes to install. Done.
What I like
-The interface is cleaner
-Mission control (aka Expose et. al) is a bit better
-Full screen is nice.
-Local Time Machine backups are nice
What I don’t like
- The scrolling. I tried it for a whole day, but it doesn’t feel natural at all, so I reverted back to the original scrolling direction.
- Finder got rid of my “Macintosh HD” in the side bar. I’m sure I can get it back, but I need to go to the root directory once in a while. it was nice having it there.
- It seems slower than Snow Leopard. Seems like my machine is running at a warmer than normal and slower than normal rate.
What broke
- I was using Zend Server CE as my local web / mysql server. That was utterly broken. Instead of just reinstalling right away I tried out the local web server following this write up by Rob Allen
http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/
Worked good, but it seemed really slow (more on that below).
So because of this apparent slowness I installed MAMP. It installed fine, but MAMP had problems resolving host names and doing network calls… Someone said it was a bug in the PHP version that MAMP ships. Anyway, it didn’t solve the speed problem either (that should have been my first clue).
I looked into installing Nginx on Mac, but didn’t have ‘make’ installed so I’ll have to pass for now.
I redownloaded Zend Server CE and installed that. Worked fine, but it was still slow.
Chrome is to blame.
- I use the local /etc/hosts file to resolve names for local development. For some reason Chrome under OS X Lion takes about 10 seconds to resolve the name when it has to use the hosts file. So every request was taking about 10 seconds… almost the whole time it was waiting for DNS to time out.
- Once I opened Safari to do local development the local web server was as zippy as before…..
Now I just have to figure out why Chrome is taking so long to resolve a name that is in the local hosts file.
[UPDATE]
To fix the Chrome slow issue… I just needed to move each entry in the /etc/hosts file to it’s own line.
so instead of
127.0.0.1 www.example.com www1.example.com
It would be
127.0.0.1 www.example.com
127.0.0.1 www1.example.com
http://superuser.com/questions/313128/lion-name-resolution-order
Doctrine Query Cache driver memcache when using ZFDoctrine
According to Doctrine’s documentation, you should always utilize a Query Cache.
http://www.doctrine-project.org/documentation/manual/1_2/en/caching:query-cache-&-result-cache
You should always use query cache in a production environment. That said, you can easily use it during development, too. Whenever you change a DQL query and execute it the first time Doctrine sees that it has been modified and will therefore create a new cache entry, so you don’t even need to invalidate the cache.
That said, you need to add the following configuration options in
application.ini
If you have a standard Memcached running locally on port 11211 then the following should work.
resources.doctrine.manager.attributes.attr_query_cache.driver = memcache
resources.doctrine.manager.attributes.attr_query_cache.options.servers.host = localhost
resources.doctrine.manager.attributes.attr_query_cache.options.servers.port = 11211
resources.doctrine.manager.attributes.attr_query_cache.options.servers.persistent = true
resources.doctrine.manager.attributes.attr_query_cache.options.compression = false
PHP inet_aton to store IP address in MySQL Database
Don’t store IP addresses in a database as a string like (192.168.10.10). That is just the human readable form of that number. You want to store it in the database as an integer.
MySQL has built in functions to handle converting a dot-notation ip address to an integer equivalent.
mysql> SELECT INET_ATON('192.168.0.10') AS ipn;
+------------+
| ipn |
+------------+
| 3232235530 |
+------------+
mysql> SELECT INET_NTOA(3232235530) AS ipa;
+--------------+
| ipa |
+--------------+
| 192.168.0.10 |
+--------------+
But, I needed this type of functionality in PHP itself. Long story short, I’m using Doctrine to handle the relationship that PHP has to the database and I need to convert the human readable dot-notation IP address to the integer style (unsigned integer that is).
PHP’s built in function ip2long comes close, but there is a little bit more to work the magic.
$ip = long2ip(ip2long("192.168.1.10"));
print sprintf("%u", ip2long($ip));
sprintf
is used to convert the signed integer to an unsigned one.
Ready to be inserted into the DB.
Zend_Tool and APPLICATION_ENV [SOLVED]
I’ve set up my project on a new server getting prepared to go live. With that comes, moving around some files getting things ready. One thing I’m working on it getting the Zend_Tool command line working.
On the server, I’ve configured
APPLICATION_ENV
to be
production
via
.htaccess
Problem
When I run
zf.sh show doctrine
it errors out because it’s trying to use my “development” DB config rather than the “production” one. I’m not sure how to get around this yet.
Solution
Not pretty, but you have to edit the source of the Zend Framework. The file to edit is
ZendFramework/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php
Here is the diff for what needs to be changed.
--- BootstrapFile.php (saved version)
+++ (current document)
@@ -106,9 +106,11 @@
define('APPLICATION_PATH', $this->_applicationDirectory->getPath());
$applicationOptions = array();
$applicationOptions['config'] = $this->_applicationConfigFile->getPath();
+
+ $env = getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development';
$this->_applicationInstance = new Zend_Application(
- 'development',
+ $env,
$applicationOptions
);
}
,
Then you need to add the APPLICATION_ENV environmental variable to your shell.
In OS X, I’ve found this to work:
Insert this at the end of your .bash_profile
declare -x APPLICATION_ENV="local"
Now you can declare an environment in application.ini that works for the Zend Tool (and ZFDoctrine in my case).
Zend Framework – Doctrine ORM strange Zend Tool behavior.
Zend Framework… awesome.
Doctrine ORB… awesome.
Both of these combined…. PURE AWESOME.
I set up a project just at it says to on this page http://github.com/fmntf/zf-doctrine. It took some doing, but I got it working and was quite happy with my initial results. Then I needed to start a new project, so I just copied all the files, tweaked the DB name was flying with a new project… with one caveat.
One of the modules I created using a YAML file was not getting created in the DB when I ran zf build-project doctrine --reload. It was frustrating, I tried changing a bunch of things.
In the end the whole problem was that the module folder didn’t have a controllers folder and that was it. So I created a controllers folder and then it created the corresponding tables in the db. I think this code has much to do with it
application/Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* This will register all the module directories with ZF
*/
public function _initModuleLoaders()
{
$this->bootstrap(‘Frontcontroller’);
$fc = $this->getResource(‘Frontcontroller’);
$modules = $fc->getControllerDirectory();
foreach ($modules AS $module => $dir) {
$moduleName = strtolower($module);
$moduleName = str_replace(array(‘-’, ‘.’), ‘ ‘, $moduleName);
$moduleName = ucwords($moduleName);
$moduleName = str_replace(‘ ‘, ”, $moduleName);
$loader = new Zend_Application_Module_Autoloader(array(
‘namespace’ => $moduleName,
‘basePath’ => realpath($dir . “/../”),
));
}
}
}
Magento and Zend Server checkout redirect to cart [solved]
I installed Zend Server CE on one of my machines. The next day I noticed that you could not checkout from the website. It would bring you to the to the Billing Address, then after you hit “continue” it would redirect you back to the checkout page. No errors that I could see.
Then I remember a problem I had many moons ago that was very similar and a forum comment jogged my memory. Magento is looking for a Com.php file buried deep in the bowls of Zend Framework.
Did you know that Zend Server includes the latest copy of the Zend Framework? Yes and therein lies the problem, the Zend Framework version of Zend Server was overriding the built in Zend Framework of Magento.
Easy solution
Open up your .htaccess file and add this section in there somewhere. This will reset your include path, Magento will build this for you anyway so it shouldn’t cause a problem.
###########################################
## Reset Include path
php_value include_path "."
Resources:
http://www.magentocommerce.com/boards/viewthread/28231/#t200692
Magento Upload HTTP Error [SOLVED]
This was a strange error with Magento. I was in a product, trying to upload an image. The image would upload fine, but then error out with “Upload HTTP Error”. I changed permissions up and down the /media and /var directories and made them as loose with permissions as I could.
Still no change.
Then I happened upon this comment in the forums.
To anyone that has a HTTP upload error AND has a password protected store directory (for under construction reasons):
remove the directory password protection and you’ll be able to upload your files again! That was what happened to me.
BINGO!
I removed the password protection for the admin (not the Magento password, but Apache basic password protection).
Reference:
http://www.magentocommerce.com/boards/viewreply/154831/
