Search

How to install laravel in android phone

post-title

In this tutorials i gonna share with you Amazing artical, "How to install laravel in your Android Phone". this artical is very helpfull for performe a small tack for laravel on your Android phone without open your PC or laptop.so let's start. i will explain all thins one by one. so please followed all step and you can easely install or run laravel applilcation in your Android Phone.

Step 1 : Install "Termux" Aplication from Google Play Store

Termux is provide all functionality like as terminal, which we are using in our Ubuntu OS. then after you simple open it application and type "apt update". My goal when testing Termux was to see if I could assemble a proper* PHP development environment, so I started by installing a text editor. I prefer Vim, but there are some more options available, like Emacs and Nano. Vim has a bit of a learning curve to it, but it gets very comfortable when you get past the basics of it. You can get Vim with the apt install vim command. If you are testing this on your Android phone, running vim will bring the first set of problems. How can I hit the Escape button? Termux has a large list of shortcuts that be used to simulate the buttons that are not available on the Android keyboards:

Command Key
Volume Up+E Escape key
Volume Up+T Tab key
Volume Up+1 F1 (and Volume Up+2 → F2, etc)
Volume Up+0 F10
Volume Up+B Alt+B, back a word when using readline
Volume Up+F Alt+F, forward a word when using readline
Volume Up+X Alt+X
Volume Up+W Up arrow key
Volume Up+A Left arrow key
Volume Up+S Down arrow key
Volume Up+D Right arrow key
Volume Up+L (the pipe character)
Volume Up+U _ (underscore)
Volume Up+P Page Up
Volume Up+N Page Down
Volume Up+. Ctrl+\ (SIGQUIT)
Volume Up+V Show the volume control

 

Step 2 : Install php and git

[ADDCODE]

You can install php and git by termux using following commant


apt install php
apt install git

Step 3 : Install Composer

You can install composer by termux using following commant


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Step 4 : Test your PHP code run or not

Then after completed above process then next is test PHP code run or not in your android phone, so how to test it? simple follow this step.


mkdir test
cd test
echo " index.php
php -S localhost:8080

after fire above command in your termux application then open your mobile phone browser and simpple type localhost:8000. If you show php information document on your mobile browser, then your PHP code fine working in you android phone.

Step 5 : Create Laravel Project

You installed PHP and composer successfully on your phone, so now you are ready for create laravel project. simply write this following command and enter.


php composer.phar create-project --prefer-dist laravel/laravel new_project

new_project is your laravel project name, so how to run it? first go in your project root directory by this command cd new_project then after write following command for run youe laravel project.


php artisan serve

Then after again open your mobile browser and type localhost:8000 Congratulation your laravel now successfully run in your android phone.

Step 6 : Install sqlite database

Now you can install sqlite database in your laravel application in your mobile phone, so first it installed by following command.


apt install sqlite

After completed this process then after you must be some changes in your laravel application files, first open your .env file and change in it look like,


DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

Then go to the config/database.php file and change the following line from:


'default' => env('DB_CONNECTION', 'mysql'),

to


'default' => env('DB_CONNECTION', 'sqlite'),

This will make sqlite the default connection from the connections array.


connections' => [
    'sqlite' => [
        'driver' => 'sqlite',
        'database' => env('DB_DATABASE', database_path('database.sqlite')),
        'prefix' => '',
    ],
    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],
    'pgsql' => [
        'driver' => 'pgsql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],
],

Your database path point to be database.sqlite file,This file does not exist yet, so we need to create it.


touch database/database.sqlite

Then after you can create auth using this command


php artisan migrate

Then after again refresh your mobile browser and show, your basic authentication create successfully if you have any question related this artical, you must be watch following video