Tag Archives: framework

Laravel Error – SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Im currenlty running my way though Laravel 5 the PHP framework and following some tutorials. If your starting this framework you will most likely run into the error below when you run your migrations;

Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))

The fix is simple;

Open the AppServiceProvider file and add the following line to the boot function;

via;

https://laracasts.com/discuss/channels/laravel/laravel-54-failing-on-php-artisan-migrate-after-php-artisan-makeauth?page=1

Angular 4/5 quick tips

 

 

 

 

 

 

how to add bootstrap:

add the scripts and styles to your “.angular-cli.json”

add the following the styles and scripts section;

create new project:

start server:

create new component:

create new service:

Cakephp 3 Plugin – Changelogs

Ive finally gotten around to releasing this little app i was working on for Cakephp3.  I decided a while ago to abandon Cakephp 2 and go with the new version 3.

Its been a steep learning curve so i wanted to learn as much as i could.  So thats where this app/plugin came in.

The Aim:
The goal of the plugin was to allow a way to simply log tasks, changes or articles about the cakephp project your working on.

If your working on a website/project on your own you need a way to record your changes and tasks so i thought this would be an ideal way to learn and release something. Sure you could do the same with Github and better but i think its better to have something like this integrated into your application.

Screenshot: Version 1
2016-05-25

 

 

 

 

 

Version 2 Screenshot:
changelogseditv2

 

 

 

 


Github & Source:

https://github.com/gerrymcdonnell/cakephp-changelog

Cakephp3-Creating custom queries

23666In your object table;

In your controller method;

So what does it do?
It will return the results where the artist field is like eg.”U2″ and where the title is like “U2”.
It also has an order clause in there and will contain the related records set “mp3files”.

Reference:
http://book.cakephp.org/3.0/en/orm/query-builder.html

CakePhp 2 Tip#8-Checking User Ownership

cake-logo

Another common task in Cakephp Applications or any Web Application is making sure that a user can only delete items they own otherwise anyone could erase your entire database.

An example you have created a users table and users can create posts, but we need to ensure that User A can only edit and delete posts belonging to them.

Solution: The isAuthorized() function.
This function will check that the user isAuthorized to do what ever action they are about to under take.

Assuming every posts has a user_id as a foreign key, we can check the current logged in user’s Id against the id stored in the post their about to modify and if they match allow and if not deny.

Entire User Auth Solution and Guide:
https://github.com/cakephp/docs/blob/master/en/tutorials-and-examples/blog-auth-example/auth.rst