Skip to content

Commit

Permalink
Review Laravel upgrade guide [API-381]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jul 24, 2023
1 parent 18428f4 commit d37b474
Show file tree
Hide file tree
Showing 25 changed files with 285 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CACHE_DRIVER='memcached'
SESSION_DRIVER='memcached'
MEMCACHED_HOST='memcache.test'

FILESYSTEM_DRIVER='local'
FILESYSTEM_DISK='local'

# One-time configs on first deploy:
DB_CONNECTION='mysql'
Expand Down
5 changes: 5 additions & 0 deletions app/Console/Commands/Import/ImportProductsFull.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands\Import;

use Illuminate\Support\Facades\Storage;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use League\Csv\Reader;

class ImportProductsFull extends AbstractImportCommand
Expand All @@ -17,6 +18,10 @@ public function handle()
// API-344: Make sure this matches upload filename in ProductController
$stream = Storage::disk('s3')->getDriver()->readStream('DatahubChainDriveProductData.csv');

if (!$stream) {
throw new FileNotFoundException();
}

$csv = Reader::createFromStream($stream);
$csv->setHeaderOffset(0);

Expand Down
13 changes: 7 additions & 6 deletions app/Library/Migrations/MigrationCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ protected function getStub($table, $create)
return $this->files->get($stubPath);
}

protected function populateStub($name, $stub, $table)
protected function populateStub($stub, $table)
{
$stub = str_replace(
['DummyClass', '{{ class }}', '{{class}}'],
$this->getClassName($name),
$stub
);
if (! is_null($table)) {
$stub = str_replace(
['DummyTable', '{{ table }}', '{{table}}'],
$table, $stub
);
}

if (!empty($this->stubPopulator)) {
$stub = ($this->stubPopulator)($stub);
Expand Down
29 changes: 19 additions & 10 deletions app/Transformers/Traits/ConvertsToHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@

namespace App\Transformers\Traits;

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\MarkdownConverter;
use League\CommonMark\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Table\TableExtension;

trait ConvertsToHtml
{
private $htmlConverter;
private $config = [
'renderer' => [
'soft_break' => '<br>',
],
];

private function getEnvironment() {
$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new CommonMarkCoreExtension());
$environment->addExtension(new TableExtension());
$environment->mergeConfig($this->config);
return $environment;
}

/**
* TODO: Consider moving this into a MarkdownServiceProvider?
*/
private function getHtmlConverter()
{
return $this->htmlConverter ?? $this->htmlConverter = new CommonMarkConverter([
'renderer' => [
'soft_break' => '<br>',
],
]);
return $this->htmlConverter ?? $this->htmlConverter = new MarkdownConverter($this->getEnvironment());
}

/**
Expand All @@ -27,6 +36,6 @@ private function getHtmlConverter()
*/
private function convertToHtml($value)
{
return isset($value) ? $this->getHtmlConverter()->convertToHtml($value) : null;
return isset($value) ? $this->getHtmlConverter()->convertToHtml($value)->getContent() : null;
}
}
27 changes: 23 additions & 4 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Illuminate\Support\Facades\Facade;

return [

/*
Expand Down Expand Up @@ -51,7 +53,7 @@

'url' => env('APP_URL', 'http://localhost'),

'asset_url' => env('ASSET_URL', null),
'asset_url' => env('ASSET_URL'),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -120,6 +122,24 @@

'cipher' => 'AES-256-CBC',

/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/

'maintenance' => [
'driver' => 'file',
// 'store' => 'redis',
],

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
Expand Down Expand Up @@ -200,7 +220,7 @@
|
*/

'aliases' => [
'aliases' => Facade::defaultAliases()->merge([

'App' => Illuminate\Support\Facades\App::class,
'Arr' => Illuminate\Support\Arr::class,
Expand Down Expand Up @@ -242,7 +262,6 @@
'View' => Illuminate\Support\Facades\View::class,

'Elasticsearch' => MailerLite\LaravelElasticsearch\Facade::class,

],
])->toArray(),

];
6 changes: 5 additions & 1 deletion config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| The expire time is the number of minutes that each reset token will be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
| The throttle setting is the number of seconds a user must wait before
| generating more password reset tokens. This prevents the user from
| quickly generating a very large amount of password reset tokens.
|
*/
'passwords' => [
// Our User model has no password
Expand Down
8 changes: 7 additions & 1 deletion config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
'ably' => [
Expand Down
9 changes: 9 additions & 0 deletions config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
'lock_connection' => 'default',
],

'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],

'octane' => [
'driver' => 'octane',
],
Expand Down
20 changes: 5 additions & 15 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
'charset' => 'utf8',
'prefix' => env('DB_PREFIX', ''),
'prefix_indexes' => true,
'schema' => 'public',
'search_path' => 'public',
'sslmode' => 'prefer',
],

Expand All @@ -90,6 +90,8 @@
'charset' => 'utf8',
'prefix' => env('DB_PREFIX', ''),
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
],
],

Expand All @@ -106,20 +108,6 @@

'migrations' => 'migrations',

/*
|--------------------------------------------------------------------------
| Column Types
|--------------------------------------------------------------------------
| This allows for modifying `timestamp` columns in migrations.
| See https://laravel.com/docs/8.x/migrations#prerequisites.
*/

'dbal' => [
'types' => [
'timestamp' => TimestampType::class,
],
],

/*
|--------------------------------------------------------------------------
| Redis Databases
Expand All @@ -143,6 +131,7 @@
'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
Expand All @@ -151,6 +140,7 @@
'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'),
'username' => env('REDIS_USERNAME'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_CACHE_DB', '1'),
Expand Down
24 changes: 12 additions & 12 deletions config/elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@

'hosts' => [
[
'host' => env('ELASTICSEARCH_HOST', 'localhost'),
'host' => env('ELASTICSEARCH_HOST', 'localhost'),
// For local development, the default Elasticsearch port is 9200.
// If you are connecting to an Elasticsearch instance on AWS, you probably want to set this to null
'port' => env('ELASTICSEARCH_PORT', 9200),
'scheme' => env('ELASTICSEARCH_SCHEME', null),
'user' => env('ELASTICSEARCH_USER', null),
'pass' => env('ELASTICSEARCH_PASS', null),
'port' => env('ELASTICSEARCH_PORT', 9200),
'scheme' => env('ELASTICSEARCH_SCHEME', null),
'user' => env('ELASTICSEARCH_USER', null),
'pass' => env('ELASTICSEARCH_PASS', null),

// Alternatively, you can log in via API keys
'api_id' => env('ELASTICSEARCH_API_ID', null),
'api_key' => env('ELASTICSEARCH_API_KEY', null),
'api_id' => env('ELASTICSEARCH_API_ID', null),
'api_key' => env('ELASTICSEARCH_API_KEY', null),

// If you are connecting to an Elasticsearch instance on AWS, you will need these values as well
'aws' => env('AWS_ELASTICSEARCH_ENABLED', false),
'aws_region' => env('AWS_REGION', ''),
'aws_key' => env('AWS_ACCESS_KEY_ID', ''),
'aws_secret' => env('AWS_SECRET_ACCESS_KEY', ''),
'aws_credentials' => null,
'aws' => env('AWS_ELASTICSEARCH_ENABLED', false),
'aws_region' => env('AWS_REGION', ''),
'aws_key' => env('AWS_ACCESS_KEY_ID', ''),
'aws_secret' => env('AWS_SECRET_ACCESS_KEY', ''),
'aws_credentials' => null,
'aws_session_token' => env('AWS_SESSION_TOKEN', null),
],
],
Expand Down
6 changes: 5 additions & 1 deletion config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
|
*/

'default' => env('FILESYSTEM_DRIVER', 'local'),
'default' => env('FILESYSTEM_DISK', 'local'),

/*
|--------------------------------------------------------------------------
Expand All @@ -33,18 +33,21 @@
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],

'dumps' => [
'driver' => 'local',
'root' => storage_path('dumps'),
'throw' => false,
],

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/storage',
'visibility' => 'public',
'throw' => false,
],

's3' => [
Expand All @@ -56,6 +59,7 @@
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],

],
Expand Down
6 changes: 3 additions & 3 deletions config/hashing.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
'memory' => 65536,
'threads' => 1,
'time' => 4,
],
];
Loading

0 comments on commit d37b474

Please sign in to comment.