I have added
app_path().'/classes',
to global.php in the ClassLoader::addDirectories array. In app/classes/helpers/Url.php I have:
<?php namespace Helpers;
class Url {
public static function prep($str)
{
if ($str == 'http://' OR $str == '')
{
return '';
}
$url = parse_url($str);
if ( ! $url OR ! isset($url['scheme']))
{
$str = 'http://'.$str;
}
return $str;
}
}
Then in a view I have:
{{HTML::link(Helpers\URL::prep($place->url), $place->url, array('target' => '_blank'))}}
This works fine locally, but on my server I'm getting an error for: Class 'Helpers\URL' not found. I tried going through these steps, but it didn't work either. Any ideas?
Ok, I found the problem. I renamed "app/classes/helpers" to "app/helpers", then added the new app/helpers to composer.json and global.php and ran composer dump. Looking through some of the PHP documentation, it seems like PHP sometimes has issues with using "class", "classes", or other reserved type words in directories and namespaces. I'm still not sure why this was working locally, but not on the server though.