Category Archives: Laravel

SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

 

SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD(‘your_existing_password’). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file

This is a small script, made by Antonio Bonifati and found at StackOverflow Cannot connect to MySQL 4.1+ using old authentication  that will update your password and it will solve this problem for you.

<?php

$hostname = '127.0.0.1';
$database = 'database_name';
$username = 'database_username';
$password = 'password';

if (!mysql_connect($hostname, $username, $password)) {
 die(mysql_error());
} if (!mysql_query($query = 'SET SESSION old_passwords=FALSE')) {
 die($query);
} if (!mysql_query($query = "SET PASSWORD = PASSWORD('" .$password . "')")) {
 die($query);
}
echo "Excellent, mysqli will now work";

exit();
?>

Laravel 5.0 – route annotation

This is are my discovers on the new routing system on Laravel 5.0.

Yah! I was trying, yesterday to use this new thing on Laravel.
Theres a huge discussion about in on Laracasts (https://laracasts.com/discuss/channels/general-discussion/route-annotation-in-laravel-5) … I’m not concerned about it… I just want it to work… how/why have they chosen this way its *their* problem.

Ok! yesterday I got a little mad with it.
I was following the book! and I wasn’t getting it to work.

This is how it works.

We need to add our controllers to app/Providers/RouteServiceProvider.php.

RouteServiceProvider Laravel 5.0

Add your new controller to the list.

On our controller

 /**
 * @Get("/tos/")
 */
 public function terms()
 {
     echo '<h1>Terms of Service!</h1>';
 }

 

After adding all your route annotations, you will need to update the “route:list” or what they call…

This is how…

php artisan clear-compiled
php artisan route:scan

and list them on console…

php artisan route:list

Your routes should work now.

 

 

 More readings

http://mattstauffer.co/blog/laravel-5.0-route-annotations
https://laracasts.com/discuss/channels/general-discussion/route-annotation-in-laravel-5
http://www.reddit.com/r/laravel/comments/2jex9b/introducing_route_annotations_in_laravel_50/

 

Can’t find routes.php in Laravel 5

f*ckzzzzz!
A video on Laracast says that routes.php is inside ./app/Http/.
Can’t find it.
sh*tttzzz!

I’m trying to figure it out and update this post! 🙂

Updates!

OK!, almost 24hours later…
But!, I hadn’t been all this time looking for the solution.

YES!, I’v seen it before and tried but didn’t worked…

I was trying to use Laravel Annotation, but with no success.

OK!, heres the real sh*t.

We can have routes.php on Laravel 5 inside app/Http.

We need to active it on app/Providers/RouteServiceProvider.php, by uncomment require app_path(‘Http/routes.php’);.

You will need to update the “route:list” or what they call…
This is how…

php artisan clear-compiled
php artisan route:scan

and list them on console…

php artisan route:list

Your routes should work now.

More readings

https://laracasts.com/discuss/channels/general-discussion/route-annotation-in-laravel-5
https://laracasts.com/discuss/channels/general-discussion/informal-poll-routes-file
https://laracasts.com/series/laravel-5-from-scratch/

 

How to install Laravel 5 5.0-dev / 4.3

Since we need composer, lets install it.

We have to have installed curl and php-cli on our server.

  • curl
    apt-get install curl
  • php-cli
    apt-get install php5-cli

Lets now install composer.

curl -sS https://getcomposer.org/installer | php

Lets now move composer to /user/local/bin/composer so we can run it anywhere in the system.

mv composer.phar /usr/local/bin/composer

Inside the folder that we want to put Laravel 5, in my case /home/webroot/domain.com/www2/ lets run

/usr/local/bin/composer create-project laravel/laravel www2 dev-develop

Simple and fast.

(…)

Inside the folder, that we installer laravel /home/webroot/domain.com/www2 lets run

php artisan -V

HOORAY! Laravel Framework version 5.0-dev!

 

References

https://getcomposer.org/doc/00-intro.md#installation-nix
http://laravel.com/docs/4.2/installation
https://laracasts.com/series/laravel-5-from-scratch/episodes/2

Laravel, confide translations / new names – confide::confide

So, imagine that we are using Laravel and creating a new form…

 <div class="form-group">
 <label for="nif">{{{ Lang::get('confide::confide.nif') }}}</label>
 <input class="form-control" placeholder="{{{ Lang::get('confide::confide.nif') }}}" type="text"
 name="nif" id="nif" value="{{{ Input::old('nif') }}}">
 </div>

We will see returned confide::confide.nif and not anything else…
How do we solve this?

Inside /app/lang/pt/ (pt is my default language… you should use yours…….) create the following file: confide.php and with a structure like the other files (duplicate,rename and change it) inside that folder create the new entries…

<?php
return array(
 /*
 |--------------------------------------------------------------------------
 | Confide Language Lines
 |--------------------------------------------------------------------------
 |
 | The following language lines contain the default error messages used by
 | the validator class. Some of these rules have multiple versions such
 | such as the size rules. Feel free to tweak each of these messages.
 |
 */
 "nome_completo" => "Nome completo",
 "morada" => "Morada",
 
 "nif" => "NIF",
 "email_confirmacao" => "Email Confirmação",

We now, have to CALL confide.nif and not confide::confide.nif.

Read more at
http://stackoverflow.com/questions/19338437/override-package-localization-in-laravel
https://github.com/laravel/framework/issues/2467#issuecomment-26211312
http://laravel.com/docs/localization#language-files