Skip to content

Instantly share code, notes, and snippets.

:octocat:
Finalizing

Juyal Ahmed tojibon

Block or report user

Report or block tojibon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tojibon
tojibon / mysql.md
Last active May 9, 2019
Search for a specific column name in all the tables in MySQL database?
View mysql.md
SELECT    
    table_name, 
    ordinal_position    
FROM INFORMATION_SCHEMA.COLUMNS    
WHERE    
    table_schema = 'DB_NAME' AND    
    column_name='column_name';
@tojibon
tojibon / composer.json
Last active May 8, 2019
Creating a package with Laravel 5.6 for a printing company ex: Alpha and the package name ex: Library.
View composer.json
{
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/",
"Alpha\\Library\\": "packages/Library/src/"
}
@tojibon
tojibon / readme.MD
Last active May 15, 2019
My Laravel Best Practices
View readme.MD
  • Always follow PSR2 - PSR4 php coding style, better install it on PHPStorm
  • Always validate things via RequestValidators even if it is nullable(), Move validation from controllers to Request classes.
  • Use child relationships to get child data and filter data
  • Make sure if there is any auto generated codes like __construct
  • How can a array count ever be less than 0? Check to use a simple condition instead of making it complex with double check
  • Check if there is anything should actually fail if it doesn't have a set value
  • It's a good idea to check first for the less costly conditions (especially inside a loop)
  • Always use Carbon for date processing
  • Maintain code commenting and proper docblock
  • Always use custom env for static values, do not get data from the .env file directly
@tojibon
tojibon / readme.md
Last active Apr 27, 2019
Setting up VirtualHost for Symfony App in Ubuntu
View readme.md
sudo vim /etc/apache2/sites-available/symfony-test-app.conf
<VirtualHost *:80>
  ServerName symfony-test-app.com
  <IfModule mod_rewrite.c>
    RewriteEngine on
@tojibon
tojibon / api.php
Last active Apr 17, 2019
Laravel fire an Artisan command from an HTTP route by using Artisan facade
View api.php
<?php
Route::get('/foo', function()
{
$exitCode = Artisan::call('command:name', ['--option' => 'foo']);
//
});
?>
@tojibon
tojibon / bash.md
Created Apr 12, 2019
Installing symfony client
View bash.md
wget https://get.symfony.com/cli/installer -O - | bash
export PATH="$HOME/.symfony/bin:$PATH"
sudo mv /home/juyal/.symfony/bin/symfony /usr/local/bin/symfony
View Artisan.md
// Added in 5.1.11:http://laravel.com/docs/5.1/authorization#creating-policies
php artisan make:policy PostPolicy
// Displays help for a given command
php artisan --help OR -h
// Do not output any message
php artisan --quiet OR -q
// Display this application version
php artisan --version OR -V
// Do not ask any interactive question
@tojibon
tojibon / gitflow-breakdown.md
Created Apr 1, 2019 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.
View gitflow-breakdown.md

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@tojibon
tojibon / mysql.bat
Created Feb 8, 2019
Connect MySQL + Create Database + Import SQL via terminal
View mysql.bat
mysql -u root -p
CREATE DATABASE phpapp_db;
CREATE USER 'phpapp_user'@'localhost' IDENTIFIED BY 'phpapp_user_pass';
GRANT ALL ON phpapp_db.* TO 'phpapp_user'@'localhost';
exit;
mysql -u phpapp_user -pphpapp_user_pass -D phpapp_db;
exit;
mysql -u phpapp_user -pphpapp_user_pass -D phpapp_db < dummy_data.sql;
View app.dockerfile
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
You can’t perform that action at this time.