Posts

PHP preg_match Regular Expression Cheatsheet

  [abc] A single character: a, b or c [^abc] Any single character but a, b, or c [a-z] Any single character in the range a-z [a-zA-Z] Any single character in the range a-z or A-Z ^ Start of line $ End of line \A Start of string \z End of string . Any single character \s Any whitespace character \S Any non-whitespace character \d Any digit \D Any non-digit \w Any word character (letter, number, underscore) \W Any non-word character \b Any word boundary character (...) Capture everything enclosed (a|b) a or b a? Zero or one of a a* Zero or more of a a+ One or more of a a{3} Exactly 3 of a a{3,} 3 or more of a a{3,6} Between 3 and 6 of a options: i case insensitive m make dot match newlines x ignore whitespace in regex o perform #{...} substitutions only once

What’s New in PHP 8 ?

Union types public function foo(Foo|Bar $input): int|float; The nullsafe operator $dateAsString = $startDate ? $startDate->asDateTimeString() : null;   $dateAsString = $booking->getStartDate()?->asDateTimeString(); New mixed type function bar(): ?mixed {} Throw expression $triggerError = fn () => throw new MyError(); $foo = $bar[‘offset’] ?? throw new OffsetDoesNotExist(‘offset’); READ -> https://stitcher.io/blog/new-in-php-8

Amazon Principles

  — This is great for other companies to be inspired — Leadership Principles We use our Leadership Principles every day, whether we’re discussing ideas for new projects or deciding on the best approach to solving a problem. It is just one of the things that makes Amazon peculiar. Customer Obsession Leaders start with the customer and work backwards. They work vigorously to earn and keep customer trust. Although leaders pay attention to competitors, they obsess over customers. Ownership Leaders are owners. They think long term and don’t sacrifice long-term value for short-term results. They act on behalf of the entire company, beyond just their own team. They never say “that’s not my job.” Invent and Simplify Leaders expect and require innovation and invention from their teams and always find ways to simplify. They are externally aware, look for new ideas from everywhere, and are not limited by “not invented here.” As we do new things, we accept that we may be misunderstood for long...

Code Review by David Raleche

Image
4 Principles are guiding this methodology - Readability - Quality Assurance - Logic - Reusable code 1 — Readability PSR-2 code styling Function no longer than 50 lines PHP doc Block TypeHint your functions Details: For better code readability we suggest PSR-2 code styling to be applied We consider a function bigger than 25 lines is not an efficient function. For engaging this methodology we recommend 50 lines maximum per function. DocBloc are essentials. Swagger in a case of API writing is essential to be present. A developer should be able to explain his work easily and quickly and should use materials to do so 2 — Quality Insurance No PHP error message No PHP Warning messages No PHP Notices No hardcore credentials Unit Testing Details: When executing the code we expect the quality assurance team to verify that no PHP errors, warnings, notices are produced. We also expect the QA team to go throughout the code to verify that no hardcore credentials are present within the code. Unit Te...

Laravel BackPack – Tutorial

  Linux  commands history 745 composer require backpack/crud:"4.0.*" 746 composer require backpack/generators --dev 747 composer require laracasts/generators --dev 748 php artisan backpack:install 749 php artisan make:migration:schema create_tags_table --model=0 --schema="name:string:unique" 750 php artisan migrate 751 php artisan backpack:crud tag 752 valet park 753 valet link 754 valet links 755 hisory 756 history 757 vim .env 758 php artisan backpack:crud building 759 php artisan backpack:crud apartment 760 php artisan backpack:crud apartment Additional Feature 830 composer require backpack/permissionmanager 831 php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations" 832 php artisan migrate 833 php artisan migrate 834 php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag=...

How to Laravel Nova? Postgres

  Create Resource php artisan nova:resource DirectMailing Create Model php artisan make:model DirectMailing -m Postgres How to deal multiple schema ? Connection variable is critical protected $connection = 'pgsql-api'; How to deal with Schema and uuids ? file location : app/LoyaltyLevels.php class LoyaltyLevels extends Model { // protected $connection = 'pgsql-api'; protected $table = 'api.loyalty_levels'; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = 'loyalty_level_uuid'; protected $keyType = 'string'; } File location app/Nova/LoyaltyLevels.php public function fields(Request $request) { return [ Text::make('loyalty_level')->sortable(), Text::make('loyalty_level_description')->sortable(), ]; }

Install Laravel Nova

  1 - composer create-project --prefer-dist laravel/laravel admin "5.8.*" 2 - add/update in composer.json the following item "repositories": [ { "type": "composer", "url": "https://nova.laravel.com" } ], Next, you may add laravel/nova to your list of required packages in your composer.json file: "require": { "php": "^7.1.3", "fideloper/proxy": "^4.0", "laravel/framework": "5.8.*", "laravel/nova": "~2.0" }, 3 - php artisan nova:install 4 - php artisan migrate