Skip to content

Instantly share code, notes, and snippets.

View csinghdev's full-sized avatar
👨‍💻

Chandresh csinghdev

👨‍💻
View GitHub Profile
@csinghdev
csinghdev / install_composer_on_ubuntu.sh
Created March 14, 2020 11:11
Installing composer on Ubuntu
#!/bin/bash
# Execute the commands below to install composer on ubuntu
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
@csinghdev
csinghdev / apache_virtualhost_example.conf
Created March 14, 2020 11:52
Apache virtual host conf file
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
<Directory /var/www/example/>
#!/bin/bash
# Execute the commands below to install composer on ubuntu
# Update brew
brew update
# Install latest version of php
brew install php
# Start php service
@csinghdev
csinghdev / Controller.php
Last active April 12, 2020 13:12
Response management functions in Controller
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use MarcinOrlowski\ResponseBuilder\ResponseBuilder;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
@csinghdev
csinghdev / ApiCode.php
Created April 12, 2020 12:13
API Codes
<?php
namespace App;
class ApiCode {
 public const SOMETHING_WENT_WRONG = 250;
 public const INVALID_CREDENTIALS = 251;
}
@csinghdev
csinghdev / api.php
Created April 12, 2020 13:18
Localization file for API Error Messages
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
|--------------------------------------------------------------------------
|
@csinghdev
csinghdev / response_builder.php
Created April 12, 2020 13:21
Response builder config file for mapping API code and messages
<?php
use App\ApiCode;
return [
/*
|-----------------------------------------------------------------------------------------------------------
| Code range settings
|-----------------------------------------------------------------------------------------------------------
@csinghdev
csinghdev / AuthController.php
Created April 16, 2020 15:13
Auth APIs using JWT in Laravel
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AuthController extends Controller
{
public function __construct()
{
@csinghdev
csinghdev / UsersTableSeeder.php
Created April 27, 2020 18:18
Simple Users Table Seeder Example
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
@csinghdev
csinghdev / LogRoute.php
Created May 7, 2020 15:43
Middleware for API Logging - Laravel
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Log;
class LogRoute
{
/**