Sunday 14 November 2021

How to Set Up Laravel 8 on Your Android Phone


 In this article, I'm going to show you how you can install Laravel 8 on your phone. 

To get the most out of this guide, you should have some knowledge of PHP and you should know what Laravel is. But if you don't, don't worry – I will explain the basics so you can get started.

What Is Laravel?

Laravel is a web application framework with expressive, elegant syntax. It's built on PHP, which means that Laravel is PHP but it makes things easier to work with.

It comes with lots of packages for various features, like authentication, so we don't need to write authentication ourselves. To learn more about what Laravel can do, you can visit the site at laravel.com.

Why I wrote this tutorial

I created this tutorial because I want people interested in programming who don't have a laptop or pc to be able to build things on their phones.

My last post on freeCodeCamp made me realize that people are interested in learning how the tech works, so that's why I'm making more guides like this.

So let's dive into it. In this tutorial I am going to show you how you can install composer.php and use it to set up Laravel 8 on your phone 🔥🔥.

I am Precious Oladele, and I'm almost 19 this month 🥴. I'm from Nigeria and I will be taking you through this process. And if you're wondering how I know so much about this, it's because I also don't have a laptop so I explore with my phone instead 😎.

Requirements

To go through this tutorial, you'll need an Android phone with V6.0+.

Set up

We need to head over to the Play Store and download Termux:

Termux is a Linux-based system which we can use on our phones. It's as simple as using your regular Linux – you can install anything, even Kali, Ubuntu, or whatever you want. But for this tutorial we will be using it to set up Laravel 8 on our mobile phone.

Download composer

Before we download composer, we need to open up our Termux app and type in this command:

termux-setup-storage

It'll ask you for storage permissions, so go ahead and click accept. Once you're done head over to https://getcomposer.org/download/.

We need to grab everything there. But before that we need to install PHP so we can use it in our app. To do that in your Termux, type in the following command:

apt install php 

and click enter. You should see this:

Once that is done head over to the composer page and grab the code. We need to do this because Termux is Linux-based. If it was Windows there would be a simple button to download composer.exe there.

Copy the whole code and head over to Termux where you can paste it in. Then click enter.

When composer is installed you should see something like this:

How to Install Laravel 8

Before we install Laravel 8, let's check to see if we have a composer.phar file. In your Termux type this command:

ls

and hit enter. You will see the available files there.

You can see the composer.phar file and a storage folder. The storage folder grants access to your file manager. Remember the termux-setup-storage command you wrote first.

Now let's install Laravel 8. To do so we can either create a project or just install it globally. But it's a bit of a long process when installing it globally on your phone because you need to set a path and so on, and it can be pretty confusing. So in this guide we will create a project instead.

In your Termux go ahead and type this:

php composer.phar create-project laravel/laravel myapp

myapp is just the project name – you can change it to whatever you want. Then hit enter and wait for the magic to happen.

When you see the below, it means that Laravel has been installed:

Easy as pie. Now to test it, you can cd into myapp by typing cd myapp. Then you can run the Laravel server with php artisan serve.

Voilà – development has started 🔥

Now you can open http://127.0.0.1:8000 in your browser and see that Laravel is running:

Also make sure you do this so your Termux app won't force close when you are coding: 😎

That's it!

Thanks for reading. I hope you learned something from this tutorial. You should now be able to install Laravel on your Android phone and start using it to build apps.

 

Sunday 9 June 2019

the recreation of thefacebook2004


Hi guys! I'm back with a new article  the recreation of thefacebook2004Thefacebook Clone is nothing more than an attempt to recreate the first version of Facebook was launched in 2003/2004 ,This project aims to be an advanced , lightweight and free clone, being written with PHP , HTML , CSS and with MySQL as data storage. we will discuss about Facebook is a social networking service launched as FaceMash in July 2003, but later changing to TheFacebook on February 4, 2004It was founded by Mark Zuckerberg with his college roommate and fellow Harvard University student Eduardo Saverin. The website's membership was initially limited by the founders to Harvard students, but was expanded to other colleges in the Boston area, the Ivy Leagueand gradually most universities in the United States and Canada,corporationsand by September 2006, to everyone with a valid email address along with an age requirement of being 13 and older

TheFacebook Clone
- Version : 1.0 

Files

index.php

terms.php

privacy.php

contact.php

social_net.php

search.php

profile.php

about.php

register.php

login.php

messages.php

read_message.php

send_message.php

edit_profile.php

edit_privacy.php

edit_account.php

edit_photo.php

my_friends.php

home.php

invite.php

faq.php

logout.php

Images

The recreation of the html, is being based only in images found on the internet.






 















 Hope this post will help you . If you enjoy my work then please share my posts with your buddies and anyone who might be interested in thefacebook2004

                                           coming soon  on Udemy

Wednesday 29 May 2019

Build Your Own Video Sharing Website LikeYouTube

Hi guys! I'm back with a new article  of how to build a video sharing website like youtube
 we will discuss about YouTube launched in 2005, no one could have imagined that it would become such a successful website. Today, YouTube is the #3 website in the world pulling in over 1 billion visitors each month...that's a lot of people. One of the biggest reasons why YouTube became so popular is because video is the most powerful way to present anything.
  Here are some amazing stats about YouTube:

More than 1 billion unique users visit YouTube each month
    Over 6 billion hours of video are watched each month on YouTube—that's almost an hour for every person on Earth
    100 hours of video are uploaded to YouTube every minute
    80% of YouTube traffic comes from outside the US
    YouTube is localized in 61 countries and across 61 languages
    According to Nielsen, YouTube reaches more US adults ages 18-34 than any cable network
    Millions of subscriptions happen each day. The number of people subscribing daily is up more than 3x since last year, and the number of daily subscriptions is up more than 4x since last year

 What is this article about?
This article will teach you step by step how to create a website similar to YouTube. So if you've ever wanted to launch a YouTube like site, you will be able to at the end of the article.

Who is this article for?
This article is for people, organizations agencies or companies that want to build their brand by presenting amazing video content. Users will be able to upload or import their videos through their admin panel, create playlists, give thumbs up or down for videos, embed videos, and so much more.
While it's a good idea to post your videos on YouTube, it would be just as good to drive a ton of traffic by having people visit your website and watching the videos without having to go somewhere else. This is great for SEO and brand visibility. 


 Monetizing Your Site
You will learn how to monetize your site with Google Adsense or banners simply by inserting your codes in whatever position you want to show ads. This will give you complete control over what ads show on your website.

Website and Video Optimization
This article will teach you how to optimize your site, menus, videos, and content pages. This will increase your visibility on search engines like Google, Bing and Yahoo!. 

Your website will have the following features:

video upload

video thumbnail generation

server side video conversion

full video player

likes + dislikes on videos

full comment system with likes/dislikes, replies etc.

video details editing

account creation

Easy-to-use interface inspired by YouTube

Front-end management for user and admin

Social media sharing (Facebook, Twitter, Google+, Email)

and much  more!

   Coming Soon

Thursday 4 April 2019

comparison between nodejs and php

PHP is not going to disappear immediately, but its positions are undermined even further by the nascent Node.js.
When the Internet exploded in the 2000s, PHP was a thing all the cool kids did. It was extremely revolutionary, because:
  • It was an interpreted language unlike C++ or Java which require the source code compilation
  • It had the ability to be used directly with HTML by mixing within its template files with a <%php ... %> markup tags
  • It had cheap shared hosting providers on Apache servers with a Linux, Apache, MySQL and PHP (LAMP) stack
  • It had a functional nature which is easier to learn than the object-oriented programming
Over the years, PHP and its apps became a monstrous technology vulnerable to security threats (e.g., SQL injections), lack of a centralized packaging registry (was Composer inspired by Node Package Manager?),inconsistent API and subpar performance. There are many better alternatives to PHP, e.g., Ruby on Rails and Django, however nothing is as approachable as Node.js.
For those of you who aren’t familiar with Node.js, or who have heard of it but can’t quite grasp the concept, here is my analogy:
Node.js is functionally similar to the PHP + Apache or ASP + IIS stacks.
Nowadays, Node.js is gaining momentum. The platform uses JavaScript. It’s functional, and its non-blocking I/O mechanism allows for a better performance. Node.js comes with a robust Node Package Manager solution and the specification, i.e., ECMAScript.
Because Node.js is a lower-level technology, it is not comparable to complex frameworks like Struts, Rails or Django directly.
Therefore, many people, whether software engineers or entrepreneurs, are often faced with the decision of “What tech stack to use” In this article PHP vs. Node.js, we’ll compare apples-to-apples approaching the question from different angles, such as:
  • Syntax
  • Context switch
  • Modules
  • Ecosystem
  • Frameworks
  • Real-time apps
  • Database apps
  • Third-party services apps
  • Web servers
  • Hosting
  • Performance

Syntax

Both platforms have access to the command line interface via $ php -i and$ node.
This snippet prints ‘Hello World’ in PHP:
1echo 'Hello World'; 
This will output the same phrase in Node.js:
1console.log('Hello World');
Note: In JavaScript semi-colons are optional except when inside of the forloops and before immediately-invoked function expressions (IIFE).
Sleep function script example in PHP:
1234echo "a"."\n";
sleep(2);
echo "b"."\n";
echo "c"."\n";
The above code will output:
1a
And then after a 2 second delay:
12b
c
If we try to re-write the code in Node.js:
12345console.log('a')
setTimeout(function() {
  console.log('b')
 },2000)
console.log('c')
This snippet will print:
12a
c
And with a 2 second delay, it will print:
1b
Note: In JavaScript, console.log() automatically adds the end of line symbol.
The for loop in PHP might look like this:
123for ($i = 1; $i <= 10; $i++) { 
  echo $i;
} 
They’re strikingly similar in Node.js:
123for (var i = 0; i <= 10; i++) { 
  console.log(i);
} 
To create an array in PHP:
1234$users = array( 
  array('name' => 'John', 'id' => 3940), 
  array('name' => 'Peter', 'id' => 8904) 
); 
To create an array in Node.js:
1234var users = [ 
  { name: 'John', id: 3940 }, 
  { name: 'Peter', id: 8904 } 
] 
To iterate through an array in PHP:
123for($i = 0; $i < count($users); ++$i) { 
  $users[$i]['id'] = mt_rand(000000, 999999); 
} 
To iterate through an array in Node.js:
123for (var i; i < arr.length; i++) {
    users[i] = Math.floor(Math.random()*1000000);
} 
Or in a functional manner:
123users.forEach(function(user, i){ 
  users[i] = Math.floor(Math.random()*1000000); 
}) 
To declare a function in PHP:
1234function hello($name) {
  echo "Hi ".$name;
}
hello("Peter"); //outputs Hi Peter
To declare a function in Node.js:
1234function hello(name) {
  console.log('Hi' + name);
}
hello('Peter'); //outputs Hi Peter
To declare a new object in PHP:
12345678class foo {
    function do_foo()  {
        echo "Doing foo."; 
    }
}

$bar = new foo;
$bar->do_foo();
To declare a new object in Node.js:
12345678var foo = function () {
  return { 
    do_foo: function () {console.log('Doing foo');}
  };
};

var bar = foo();
bar.do_foo();
Note: there are no classes in Node.js/JavaScript, because objects inherit directly from other objects (prototypal inheritance). There are many instantiating patterns such as pseudo-classical, functional(above) andclassical.
A database snippet with the PDO database connection library in PHP:
1234$pdo = new PDO('sqlite:users.db');
$stmt = $pdo->prepare('SELECT name FROM users WHERE id = :id');
$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT); //<-- Automatically sanitized by PDO
$stmt->execute();
A Node.js database script with the Mongoskin MongoDB library:
123456//assuming we use Connect/Express middleware for req.query
var db = require('mongoskin').db('localhost:27017/db'); 
db.collection('users').find({_id: req.query.id}).toArray(function(err, results) {
    if (err) throw err;
    console.log(results);
});

Context Switch

The Switch between different environments and languages is attributed to the drop of efficiency when writing software code. Many researches and personal anecdotal observations show that interruption negatively impacts programmers’ performance. With less languages to learn and remember the flow is smoother and the code is better! For a deeper articles on this subject you might want to take a look at Human Task Switches Considered Harmful and The Multi-Tasking Myth.

PHP

With the LAMP stack, i.e, Linux, Apache, MySQL and PHP, developers must master at least two more languages which are PHP and SQL in addition to the mandatory and omnipresent HTML, CSS and JavaScript.

Node.js

Node.js is brilliant at having less context switches, because together with MongoDB, this stack can operate only in one language: JavaScript!
An example of MongoDB shell commands (called by $ mongo):
123> db.users.find({});
> db.users.insert({name: 'Azat', email: 'azat@rpjs.co'})
> db.users.update({name:'Azat'},{$set:{email:'hi@rpjs.co'}})

Modules

PHP

There is PEAR, a veteran system which installs packages on a server globally, and a better alternative Composer.
In other cases, developers had to seek modules — or components as they call them — on various websites, and to administer them manually by placing *.php files into sub-folders of their projects. Unfortunately, all this is not very kosher.

Node.js

Node.js comes with a superior and dependable package management system called NPM and its registry npmjs.org which is easy to use and publish. Everything is administered via the package.json file and versioned locally, unless we’re installing a CLI tool with the -g option.
Both PHP and Node.js are functional languages with a relatively later addition of OOP to PHP.

Ecosystem

PHP

This is probably one of the most important areas where PHP still beats Node.js. There are amazing open-source applications, e.g., WordPress, tons of free scripts, quality tools and books.

Node.js

Node.js is growing faster than any other platform/language. This is mostly due to the philosophy of keeping modules minimal and performing only a small set of tasks. Other factors might include such things as:
  • The gigantic popularity of front-end JavaScript among web developers
  • Existence of the specs, and abundance of JavaScript resources and gurus (such as Doug Crockford) amassed during the language’s many years of existence
  • Collaborative GitHub open-source community based on an awesome distributed version control system that didn’t exist before
  • Ease of NPM use, e.g., to publish an NPM module run $ npm publish
As a result, some people predict that Node.js will surpass other languages in the absolute number of contributions.

Frameworks

It’s important to have rich tools and proven libraries at our disposal.

PHP

CakePHP and Zend come to mind, and for more choices there is anextensive list.

Node.js

Playing field is relatively leveled with Express.js being the most popular choice, and the full-stack MVC frameworks Meteor and Derby showing the way to the future.

Real-time apps

PHP

For PHP, there is still Node.js dependent Elephant.io and some other approaches. The problem with native PHP and websockets is that Apache and ISS — where PHP is usually run as a module — weren’t really built with persistent connection in mind. Therefore, developers have to use the standalone processes like: Apache WebSocket or Ratchet.

Node.js

Real-time apps building is just a breeze with Node.js stack of the Socket.IOlibrary, Express.js framework and Handlebars reactive template engine. In the Meteor and Derby projects, real-time apps building is taken one step further by combining front and back-end code bases with the persistence layer which reduces the complexity and speeds up the development dramatically.

Database apps

PHP

PHP has a long and fruitful history with traditional/relational databases like MySQL, hence the name of the stack LAMP — Linux, Apache, MySQL and PHP.

Node.js

Node.js is natural with NoSQL databases like MongoDB.
The databases’ performances are somewhat comparable to each other depending on the use cases as per MySql vs MongoDB performance benchmark(MySQL), Simple Test : MongoDB vs MySQL(MongoDB) andMongoDb vs MySql – Fight!!!(MongoDB) articles. However, MongoDB is superior for distributed databases and is highly scalable. The added bonus is that without a fixed schema, NoSQL databases are perfect for cloud computing, prototyping and agile projects.

Third-party services apps

PHP

As is the case with many traditional languages, PHP’s flow is blocked ’til the remote server has responded, hence the need for multi-threading.
Note: Some languages provide this feature when special libraries/frameworks such as EventMachine for Ruby or Twisted for Python are used. However, they’re very complex and weren’t built from the ground up with the platform.

Node.js

On the contrary, due to a non-blocking I/O, Node.js can handle multiple requests and make multiple requests as a client to a third-party services (e.g., Twitter, Amazon) with just one thread of execution.

Web Servers

PHP

Since PHP 5.4 and higher, there is a build-in development server that we can started with:
1$ php -S localhost:8000
Assuming we have index.php in that folder:
123<?php
  echo 'Hello World';
?>
For versions prior to 5.4, there are ‘all-in-one’ tools like MAMP and XAMPP.
As for the production environment, PHP can’t be run on its own. One of the most popular technologies used with PHP are Apache and nginx where PHP is just a module of Apache web server. My personal experience of Apache is that it has a steep learning curve and while being very configurable, by default those configurations are prone to security leaks.

Node.js

Node.js was created from the ground up for the network applications and there is a set of core modules to write web servers.
To start a Node.js server:
1$ node .
Assuming our index.js file in this folder has:
123456var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
In production, Node.js can be run on SmartOS or Linux (like Ubuntu) as a service.
Note: Multi-threading is absolutely possible in Node.js with clusters and/or external modules.

Hosting

PHP

PHP owes its popularity mainly to the ease and cheapness of offered shared hosting solutions. True, it’s hard to find one without the LAMP stack on it. This commoditization sometimes leads to security holes and less than acceptable downtime due to hosting providers overselling and other consumers using malicious code.
Platform as a Service is a better alternative and somewhere in between full fledged dedicated server and shared hosting. Most of PaaS providers support PHP right of the bat.

Node.js

Node.js works nicely on PaaSs, with Heroku and Nodjitsu leading the list. Also, the cloud infrastructure company Joyent (the maintainer of Node.js), developed powerful operation system SmartOS that allows for performance bursts, painless deployment and DTrace debugging.

Performance

It’s needless to say that performance is important. This resource shows different benchmark tests: Which programs are fastest?.

PHP

PHP is relatively fast but due to its bottleneck in the file system, database and third-party requests, it fails miserably in comparison with Node.js and its super fast Goolge Chrome V8 engine.
For example, when Facebook reached its scalability limits with PHP, they wrote an extremely fast C++ library and virtual machine which they calledHipHop VM, but kept the PHP API.

Node.js

Node.js is extremely fast due to its non-blocking I/O mechanism and Google Chrome V8 engine technology. I even heard that Joyent started re-writing some of their C++ modules in Node.js.

Conclusion

PHP was an outstanding technology in its days. Its success and popularity came from:
  • Its ease of learning and use
  • cheap and straightforward hosting mostly shared LAMP
  • Abundance of open-source scripts, apps and libraries
At the same time, these same things now led to its dusk. The contributions to the core from beginner programmers metamorphosed API inconsistently while the lack of OOP/classes and module management systems inhibited open-source community growth. Absence of a leading framework (Ruby on Rails comes to mind as an example of a single dominance) or a paradigm that also helped to produce a lot of bad code that relied heavily on mixing PHP and HTML code without any MVC-ishness. On the other hand, there are a lot of good products and infrastructure for PHP that are here to stay.
Node.js is relatively young with only three years since its first commit, but it’s already the fastest growing platform by the pace of contributions (the absolute number will surpass other languages in a few years). The fact that JavaScript language is the most popular language in the world and has the biggest run-time internment of course attributed to that. Many tools are ported to Node.js with small or no modification from the browser environment. Also, great books on JavaScript fundamentals (for example,JavaScript: The Good Parts and Eloquent JavaScript) experienced surge in the popularity again.
Node.js is very efficient and great for building real time, NoSQL oriented and scalable systems.

Disclaimer

I worked with many technologies including Ruby on Rails, Python, Java/J2EE, VB, ASP, Perl and of course PHP. One of my most complex PHP projects was openList.co which involved use of the MVC pattern with template engines, classes, database abstraction layer and .htaccess re-routing. However, my focus during the past couple of years has been dedicated solely to Node.js and front-end JavaScript frameworks like Backbone.js. So my opinion might be biased, please comment on your experience with real projects in both PHP and Node.js.
If you want to learn more about Node.js take a look at my artisanal bookRapid Prototyping with JS: Agile JavaScript Development, premium online training Node Program (Udemy link) and the astonishing coding intensive full-time course at HackReactor.