Saturday, October 19, 2013

The Response content must be a string or object implementing __toString(), "boolean" given. Laravel4

"The Response content must be a string or object implementing __toString(), "boolean" given. Laravel4" .

This kind of error will kill you if yo are going to debug it Or trace it step by step, you will never find the solution because this error happens in response, I mean that it will be detected by the framework only after the response is ready to be rendered ,So it is as the message said "the response is boolean". Often it will happen in the view that some variables affect the response content . Just check the view variables one by one ,and remove each of them the try to run again . you will find the variable that cause this error. But before going in this path try to change the view by any other view page (blade-template) and see if the error is still there . if it is not , then the problem in the view page.

Sometime this error caused by directly returning false :

 
return false ;
Just change it to :
return 0;

Thursday, October 3, 2013

How to Exclude Folders From Git Gui on Windows

On the main Folder of your project create new file and name it .gitignore, This file will be read by git gui every time and all statemens will taken in account for Not tracking files or folders.

If you want to exclude a folder called "bin" , write a new line in this file "gitignore" like this:

bin/

here the bin folder located in the main folder will be excluded, if the folder you want to exclude is a subfolder,then you need to write :

bin/subfolder/

Ok, after that you have to order Git to remove cached file and remember what you have done here.
from the command line "cmd.exe" , write the following:

c:\project\git rm -r --cached .

//Don't forget the dot in the end of the command line.

then : run the following command:

c:\project\ git add .


Now any chenges made to the folder you specified in gitignore file will not be tracked.




Saturday, August 17, 2013

SQLSTATE[42S02]: Base table or view not found: 1146 Table - Laravel Eloquent

If you got this error and you know for sure  that you are having the table name in your  database, Then the problem is the prefix of the table, why is that ?
I have my model declared like this :

class tableName extends Eloquent{} 

Now eloquent will take in account that table name in the database is table_names , As you see, it will add underscore before the capital letter and "s" for plural .this will happen by default unless you explicitly declare the name of the table inside the model class like this:

class tableName extends Eloquent{

protected $table = 'tableName'; 


}

Or Avoid the Capital letter in the name of the model.

Saturday, August 10, 2013

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

This error happened if you are updating from MySQL 5.5 to MySQL 5.6 or when are using data folder that was on 5.5 server on 5.6 server . 
Anyway the solution is very easy and it is just a Warning but it is great to clear such things when you found it on your event log file.
 Add this line to MySQL configuration file , my.cnf or my.ini :

 explicit_defaults_for_timestamp = TRUE 

 restart your MySQL server and check your events log file.

Friday, August 9, 2013

NetworkError: 403 Forbidden Wamp Apache css js files

"NetworkError: 403 Forbidden   Wamp Apache css js files
SyntaxError: syntax error  <!DOCTYPE html>

Sometimes the Apache server cannot load static files other than html pages like images files, script and style files . when you have this error, that means some of the server configuration rules block the loading of these file and almost it will be in the Directory directive in http.conf file. So check the apache configuration file for Directory directive - Options Method - it may be duplicated in the main configuration file and the virtual host configuration file if you have virtual hosts, or it is not set .

if you get an error "forbidden" on directory with no index file then turn on the autoindex apache module or provide an index file if you don't want to list the files in that directory.
Other cause of this problem is that ,the server cannot reach the javascript files or there is a typing error in the syntax of the javascript tag check the script tag and the src attribute .

Tuesday, July 23, 2013

Adding new classes or library to laravel 4

The ugly, lazy and awful way: At the end of bootstrap/start.php , add an include('tools.php') and place your function in that new file.



The clean way: Create a library. That way it'll be autoloaded ONLY when you actually use it.
  • Create a library folder inside your app folder
  • Edit start/global.php to add app_path().'/library' to the ClassLoader::addDirectories( array.
  • Edit composer.json to add "app/library" to the autoload array.
  • Run composer dump-autoload
  • Create your library file, create a class in it, and add static functions to it
  • Call your class and static functions from your views.
Credit goes to this guy

Thursday, July 4, 2013

Less Compiler repeat (Duplicate) CSS rules (Definitions)

Sometimes After writing a new mixins (functions) for less and try to compiling the less files I find the produced css file include repeated definitions of the mixin children mixins , I mean that when writing a function like this :

In the LESS file I wrote the following:

.className{

h1{font-size:90%;}

p{font-size:80%;}

}



div.className;



In the output CSS file, It will be like this :

div.className h1{font-size:90%;}

div.className p{font-size:80%;}

div h1{font-size:90%;}

div p{font-size:80%;}


So, What is the Solution here ?
The problem showed a lack of knowledge in less mixins essentials . because when you create a mixin for a class, then in order to use it as a css class,  you should declare it  as a reference for the class of the element .So we will write or less file again as follows:
.className(){

h1{font-size:90%;}

p{font-size:80%;}

}



div.classname{

.className() ;

}


Now the output css file will be like the following:


div.className h1{font-size:90%;}

div.className p{font-size:80%;}