Skip to content

Instantly share code, notes, and snippets.

View mknparreira's full-sized avatar

Maikon Parreira mknparreira

View GitHub Profile
@mknparreira
mknparreira / php-bug-fix-unknown-failed-opening-required-on-line-0.md
Last active August 12, 2021 22:19
PHP | Bug fix Unknown Failed opening required on line 0

Introduction

Sometimes can occoured an error just like this:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\NC World\ProjectName\server.php' 
(include_path='C:\xampp\php\PEAR') in Unknown on line 0

To fix this, must create a file called index.php and put on public/ dir

@mknparreira
mknparreira / php-cs-fixer-example-2.md
Last active August 12, 2021 22:19
PHP CS Fixer | Example 2
$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
    ->name('*.php')
    ->notName('_ide_helper.php')
    ->notName('*.blade.php')
    ->notPath('bootstrap')
    ->notPath('node_modules')
    ->notPath('storage')
@mknparreira
mknparreira / linux-edit-host.md
Last active August 12, 2021 22:20
Linux | Editing a host

Open the cmd (Ctrl + Alt + T) and do the following command

sudo nano /etc/hosts

and add

127.0.0.1 .

@mknparreira
mknparreira / windows-editing-a-host.md
Last active August 12, 2021 22:21
Windows | Editing a host

Click Start > All Programs > Accessories > Notepad. Click File > Open. (Open as administrator) In the File name field, type C:\Windows\System32\Drivers\etc\hosts. Click Open. Make the necessary changes to the file. Click File > Save to save your changes.

After that, put on this code below:

127.0.0.1 .

@mknparreira
mknparreira / php-visual-studio-code-php-unit-windows.md
Last active August 12, 2021 22:22
PHP | Visual Studio Code | PHP Unit for Windows
{
 "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
 "phpunit.php": "C:\\xampp\\php\\php.exe",
 "phpunit.phpunit": "C:/xampp/htdocs/talentsuite/htdocs/vendor/phpunit/phpunit/phpunit",
 "phpunit.args": [
    "--configuration", "C:\\xampp\\htdocs\\talentsuite\\htdocs\\phpunit.xml",
    "--testdox"
 ]
}
@mknparreira
mknparreira / php-code-sniffer-phpcs.md
Last active August 12, 2021 22:22
PHP | Code Sniffer phpcs.xml file
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
    <description>The Laravel Coding Standards</description>
    <rule ref="Generic.Classes.DuplicateClassName"/>
    <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
    <rule ref="Generic.CodeAnalysis.EmptyStatement"/>
    <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
    <rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
    <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
@mknparreira
mknparreira / php-php-cs-fixer-file.md
Last active August 12, 2021 22:24
PHP | PHP CS Fixer .php_cs file
$excluded_folders = [
    'bootstrap',
    'config',
    'database',
    'node_modules',
    'public',
    'resources',
    'storage',
    'vendor'
@mknparreira
mknparreira / laravel-group-query-result-by-day-month-year.md
Last active August 12, 2021 22:24
Laravel | Group query result by day month year

Introduction

Quick tip for those who want to list some events, grouping them by some date value – by day, month, year etc.

Let’s take a look at example – we have this database structure of appointments.

$days = Appointment::whereBetween('start_time', [now(), now()->addDays(7)])
    ->orderBy('start_time')
    ->get()
 -&gt;groupBy(function ($val) {
@mknparreira
mknparreira / visual-studio-code-settings-json.md
Last active August 12, 2021 22:24
Visual Studio Code | settings.json
{
    "workbench.colorTheme": "Monokai",
    "files.autoSave": "onFocusChange",
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.autoClosingBrackets": "always",
    "editor.autoClosingQuotes": "always",
    "editor.mouseWheelZoom": true,
    "workbench.editor.highlightModifiedTabs": true,
 "workbench.editor.enablePreview": false,
@mknparreira
mknparreira / php-phpunit-visual-studio-code-windows.md
Last active August 12, 2021 22:25
PHP | How to configurate PHPUnit to Visual Studio Code for Windows

Step I

Open the settings.json file and put it on this following configuration:

{
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "phpunit.php": "C:\\xampp\\php\\php.exe",
  "phpunit.phpunit": "C:/xampp/htdocs/talentsuite/htdocs/vendor/phpunit/phpunit/phpunit",
  "phpunit.args": [
 "--configuration", "C:\\xampp\\htdocs\\talentsuite\\htdocs\\phpunit.xml",