Checking Mime-Type of External URL Using PHP

I was overwhelmed by Mime-Type while I was working for a project. The problem is I don’t know how to retrieve the mime-type from a file, particularly file from another host. This url is the one I want t check its mime-type. Why do I have to check it? Because it doesn’t have proper extension for an image. Look how it shows ‘?v=1423061058’ as its extension. What is it!!!??

Continue reading Checking Mime-Type of External URL Using PHP

Laravel 5 belongsToMany() by Using Pivot Table Example

Relationship using pivot table in Laravel 5? A method, belongsToMany(), is a part of Eloquent ORM in Laravel 5. It connects between tables and it has many to many relationship. In order to use it, you must have two models three tables.

Continue reading Laravel 5 belongsToMany() by Using Pivot Table Example

Blade Template Doesn’t Work in Laravel 5

No, that’s not true the Blade Template is still working in Laravel 5, but its tag directive has been changed. For some of you who don’t read the Laravel development change log may not know about this. The documentation said that “For better security by default, Laravel 5.0 escapes all output from both the {{ }} and {{{ }}} Blade directives”. So, what is the new directive?

Continue reading Blade Template Doesn’t Work in Laravel 5

How to Add Form Class in Laravel 5

Many of you will question about the error like HandleExceptions->fatalExceptionFromError( array('type' => '1', 'message' => 'Class 'Form' not found' or
FatalErrorException in 193a332e9290704ad006bafdbd047286 line 2: Class 'Form' not found
. Hmm, you must be just upgrading your Laravel 4 to Laravel 5 weren’t you?

Laravel 5 doesn’t include the Form class like the previous version. It doesn’t matter why, but I think it loses great its great feature. Then, how to make it available like Laravel 4? Several steps are needed to get it work.

Continue reading How to Add Form Class in Laravel 5

How to Change public To public_html On Laravel 5 Ubuntu

Laravel 5 has different level from previous version. It becomes simpler and it has different file structure. That was making me confused at the first time when I was trying to migrate from previous version. The odd is bootstrap/paths.php doesn’t exist anymore. Now, how do I set the public folder of my project to desired one?

I thought it was simple, but lately I can’t find the settings are. I found it blank page after I changed the public folder to public_html. Then I tried to look up the public/index.php. I found something interesting about how it processes the index.php itself. It made me come to the conclusion that I don’t need to set any configuration to get public folder to public_html works.

Then why I saw the blank page? Well, I am not a programming Guru, but I knew what’s happening there. It looks like Laravel processes it files first before it’s ready to be served to users. That’s why Laravel need folder to store the processed files. It is called storage folder.

I checked the storage and I found it has no write permission for the application. So, I changed it to 777 recursively. Then, it works.

Damn. I forgot to mention that I was using Apache web server to serve Laravel 5. But, if you are going to use php artisan serve command all I’ve mentioned above won’t work. Instead, use the Wood Marks way. Thanks to him.

Handling 404 Errors NotFoundHttpException

First off, I want to thank to my grandfather, granma, mother, father, sister, brother, and whoever read this, especially Google who gave me only partial answer to my problem. So, here I create one of my complete solution to handle the 404 Errors on Laravel.

Why my Laravel keeps showing the NotFoundHttpException error? Usually it appears like Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException.

Why NotFoundHttpException

It is because Application Debug Mode in your Laravel/app/config/app.php is set true. You can change it from ‘debug’ => true to ‘debug’ => false.

Creating Handle for 404 Error

First you have to set the Application Debug Mode to false, if it’s already done you can continue. Open your Laravel/app/start/global.php and then find the Application Error Handler section. You must find something like this.

App::error(function(Exception $exception, $code)

I know you are lazy. Change the script by copy-pasting the script below. And don’t forget to save.

App::error(function(Exception $exception, $code)
	if (Config::get('app.debug')) {

    switch ($code)a

        case 404:
        	return Response::view('errors.missing', array(), 404);
        	return Response::view('errors.missing', array(), $code);

Creating Custom Page for 404 Error

Now you create new folder named ‘errors’ in Laravel/app/views/ anad create missing.blade.php. So, the full filepath will look like this Laravel/app/views/errors/missing.blade.php.

You can fill the missing.blade.php with words, statements, and whatever you like. But please do not harass me. If you want to see complete documentation about handling error 404 in Laravel you can visit this Laravel Error Handling documentation, it’s very very very very complete. You must be come back here again after read that bullshit docs. Cheers

Can’t Install Laravel Via Laravel New

I’ve been thinking about why can’t I use laravel new [folder] to create a new Laravel installation. It seemed to be frustrating me like a dragon firing fireball into the castle. Stop that too much. Enough.

So, the reason you landed on this page is because you got error message [GuzzleHttp\Exception\ClientException] Client error response [url] [status code] 404 [reason phrase] Not Found. I must be right! Why that annoying message tends to be appeared when you try to create new Laravel installation? It’s maybe the is not available anymore. So, what are we gonna do? It’s maybe something has to be updated but the Laravel developers seem not in the mood to talk about it.

Yeah I found the solution

I just remind you that it was very frustrating to install Composer and Laravel for the first time. To fix this situation you have to locate the installation directory for Composer. If you forgot, please recall your memory. Nope, this is my installation path.


Updating the Composer

Okay first, get into your composer installation path. Then, try to update by running php composer.phar update in your command line application, in this case I used the default Windows Command Prompt. If you get message like Warning: This development build of composer is over 30 days old. It is recommended to update it by running “composer.phar self-update” to get the latest version, you should run php composer.phar self-update instead the first one.

If it worked you’ll get a message like Updating to version 31eadc6920cd1866xxxxxx. Downloading: 100% Use composer self-update –rollback to return to version 1e27ffe22813df20xxxx

Updating the Laravel Installer

Still in that Composer installation path. Now run.

composer global require “laravel/installer=~1.1”

If you’re doing it correctly this message will fulfill your happy day.

Changed current directory to C:/Users/xxxxxxx/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing laravel/installer (v1.1.2)
  - Installing laravel/installer (v1.1.3)
    Downloading: 100%

Writing lock file
Generating autoload files

Installing Laravel

NOW it’s time to kill the dragon. Execute this command my lovely soldier.

laravel new test

A folder with Laravel installation will be created in “test” folder if you did it right. I assume that you have added Composer installation path in your PATH environment. If you don’t know how to work it out you can read How to set the path and environment variables in Windows.