Skip to content

Instantly share code, notes, and snippets.

View azibom's full-sized avatar
🏕️
Focusing

Mohammad Reza azibom

🏕️
Focusing
View GitHub Profile
@azibom
azibom / php_note_1.md
Last active May 12, 2020 14:22
Php note

What does Use do in php?

Use doesn't include anything. It just imports the specified namespace (or class) to the current scope

Link

require vs. include

The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.

require_once vs. require

The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.

link

What are PHP Namespaces?

Namespacing does for functions and classes what scope does for variables. It allows you to use the same function or class name in different parts of the same program without causing a name collision.

In simple terms, think of a namespace as a person's surname. If there are two people named "John" you can use their surnames to tell them apart.

link

@azibom
azibom / nginx_reverse_proxy
Created June 23, 2020 09:49
nginx reverse proxy
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
@azibom
azibom / laravel_log_permission
Last active June 24, 2020 11:57
laravel log permission
sudo chown -R $USER:www-data storage;
sudo chown -R $USER:www-data bootstrap/cache;
chmod -R 775 storage;
chmod -R 775 bootstrap/cache;
@azibom
azibom / apt_repository
Created June 28, 2020 17:16
apt repository
/etc/apt/sources.list.d/
/etc/apt/sources.list
@azibom
azibom / php_note_4.md
Created July 21, 2020 13:27
find php.ini path

php -i | grep "Loaded Configuration File"

@azibom
azibom / phpcs.xml
Last active October 23, 2020 14:11
That is my custom phpcs.xml file
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Azibom Phpcs">
<description>
I am Azibom and that is my custom phpcs.xml file
</description>
<file>./src</file>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
@azibom
azibom / git_info.md
Created October 31, 2020 11:20
Git info

How rename the branch:

git branch -m <new_name>

How undo the commit:

git reset --soft HEAD~1

How remove the remote branch:

git push -d origin

How sync with the remote branch:

git reset --hard HEAD
git clean -f -x -d -n
@azibom
azibom / elastic.md
Created October 31, 2020 11:37
elastic

Get all indexes:

GET /_cat/indices/

Get all info about the index structure:

GET /<index_name>/_mapping

Get all data that are inside the index:

GET //_search