How create your first cakephp project without errors ?

Previously I have experienced cakephp 2.6.1 RC and now I’m going to show to how to create your cakephp project using composer. In the previous version that I’ve used (2.6.1 RC) was a bit dull 😦 , because I’ve simply download it as a default  zip archive and unzipped and used it for developments . In the versions up to 3.x the developers of cakephp added the “composer”  dependency manager to give the real developing experience to the users 🙂 .

Ok , lets start …

before this your development environment must have the following requirements,

  • php version >=5.6.4 , php 7 is good 🙂 .
  • Composer dependency manager
  • Apache (httpd) server 2.4.
  • Mysql database server >= 5.6 .

In this example I’ve used wamp server 2.5 on windows and updated the php version to 7.0.23 on wamp.

first you must open a command prompt on windows and move to “wamp\www” folder and issue the following command ,

c:\wamp\www\ composer create-project –prefer-dist cakephp/app test_cake3

then you must wait for 2 to 4 minutes to install the cakephp project on your computer.

After that move to the newly created project folder typing the following command

c:\wamp\www\ cd test_cake3

Then  you must issue the following command to run the project

c:\wamp\www\test_cake3\php -S localhost:8000 -t webroot

Here the “webroot” is your assets directory

So you can get the below as the welcome screen 🙂 ..

cake_first_run

Ok , that rocks 🙂 , But it shows an alert in red as show in below screenshot 😦 ..

cake_db_error

So , How to resolve this ?

Here we have to do two things,

  1. Make the “my_app” database and,
  2. Edit the “config/app.php” file parameters.

Ok , lets do it 🙂 .

First open the mysql cli and issue the following command on it.

make_mysql_schema

After that edit the “config/app,php” file. Scroll down the code until you find “Datasources” settings.

The default configurations of “config/app,php” file as below,

default_db_param

Apply the database name, username and password settings according to your mysql server settings. Here I have applied my computer’s mysql server parameters 🙂 as below screenshot.

modified_db_param

After that save the settings and refresh your cakephp welcome page . Here you can see that red  icon goes green 🙂 .

after_resolving_db_params

So this is the method of fresh installing cakephp version 3.x project , here in my case “3.5.2 red velvet” on windows environment  : -).

Have a nice day 🙂 … !

Advertisements
How create your first cakephp project without errors ?

Simple DIY hardware hack for address conflicting I2C devices

Recently I’m doing some experiments with beagle bone black SBC’s I2C bus and encountered some errors with devices that have the same address . One device is DS1307 with an eeprom( 24C32) and the MPU6050 DMP module that I’ve got from ebay.

d444a63a07bbf3b5080acf6133246edf-arduino-clocks

f04878-mpu-6050-module-3-axis-analog-gyro

Both DS1307 and MPU6050 hold the hexadecimal address 0x68 . So the beagle bone black’s I2C bus is confused when detecting the two devices. Then I’ve searched for the options . The DS1307 address can’t  be changed , it’s fixed one . So I have to choose the second option. Ground the AD0 pin of MPU6050 with VCC pin . So I soldered a little wire connecting both AD0 and VCC pins together shown as in below figure.

20072017396

So after doing this simple diy hack the MPU6050’s device address should be 0x69. OK , let’s test the addresses that connected to the I2C bus of the beagle bone black using the following command.

$ i2cdetect -r 2

So this is the result I’ve got 😀

i2c_address_changed

Aha 🙂 that diy hack worked well!.

That s it 🙂

So I’ve now ready to continue the experiment.

Important :- In this experiment I’ve used MPU6050 as a test device and it has AD0 pin. Here I’ve change the pin logic to 0 to 1 and that changed the  device address 0x68 to 0x69. Also keep in mind that this is a one method. Some I2C devices has software based address changing methods . In that type of devices we must read the manual and use a special firmware to change the I2C device address. We can use arduino like microcontroller to run that special firmware to do that task.  

Have a nice day!

Image

How to create your first ROR app with mysql database support on windows?

When you are creating your first app on ruby on rails it default supports “sqlite” database. You can see it while open the “Gemfile” of  your project using a text editer like “Sublime Text”. When your app’s data are growing  bigger n bigger the “sqlite” is not suitable to store that data. So there are some alternative database systems for that like “mysql”,”postgresql” or “oracle”. My preferred choice is mysql. So .in this post I’ll show you how to create you first ROR app that includes mysql database support.

First you have to install gemfile for mysql . This can be install issuing the following command in the terminal window.

 gem install mysql2

After that you can see the following progress on the terminal window

installing_mysql2_rubygem_on-windows

Then issue the following command to create new rails app that includes mysql support

 rails new testr -d mysql

After few minutes that will create your new rails app.

Now move to the development directory issuing the following command on terminal window.

 E:\>cd testr

Then issue the following command in  the terminal to run the app

 E:\testr> rails server

rails-_boot_up

Then open your web browser and  type the following url in the address bar

 http://localhost:3000

database_error

Oops.. ! . There is an error occurred 😦 . What can we do to resolve that error ?.

Ok, lets examine the database.yml in your app directory (in my example testr) using “Sublime Text” editor.

database_yml_sublime

It shows us that there is a predefined database “testr_development” and we haven’t a database in our mysql server.

So to get rid of this we open the mysql command line interface and must issue the following command in it

 mysql> create schema testr_development;

testr_database_schema

After that refresh the browser window and also see the terminal window. You can see that following  result shows mysql is correctly configured with you project.

terminal_suucess_rails.png

suucess_ror_mysql

Yay! Now you know how to make ROR app with the support of mysql database.

Thats all .

Have happy coding and have a nice day 🙂 !

How to create your first ROR app with mysql database support on windows?

How to update the ruby version on heroku ?

When we want to update the ruby version of our heroku hosted ruby website, heroku eventually send a notification for it when there is need to update the ruby version of the heroku app.

This post shows how to update the ruby version on heroku,

These are the prerequisites on your windows machine before begin the update process

  1. Node.js
  2. Ruby 2.2.4
  3. Heroku toolbelt
  4. Git 1.8.6 >

That’s it.

Then you have to login to heroku account using this command

$ heroku login

 

 

 

Then you have to clone the site folder using git.

 

 

 

After that you have to move to the cloned site folder

 

If you want to update the bundler version of your site issue the following command inside the folder

 

 

Then configure the heroku build packs if your heroku ruby project issuing following command

 

 

 

To lock the bundler version if you have encountered an error we must have to lock it to specific version issuing following command in the terminal

heroku-lock-bundler-version

After that open the gem file using your favorite text editor “notepad++” or “sublime text”

Then you have to add the following line to your ruby gem file inside your cloned folder.

You must add this line after the “source ‘https: //rubygems.org’ ” line

ruby “2.2.4”

sublime_edit_gem_file

https://devcenter.heroku.com/articles/ruby-versions

Then save the gem file, that’s all

There is no need to change the other lines of this file

Then issue the following commands one by one to push the source repository to the heroku.

 

 

 

 

That’s all after that you’ll see following successful progress screen

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This is the final result after updating the ruby version “2.0.0” to “2.2.4”

final

Thats all . Have a nice day 🙂 !

 

How to update the ruby version on heroku ?