Closed dror-avigdor closed 3 years ago
Issue solved: due to Composer ver 2 changes as regards to psr-4 autoloading standards, had to change the SqlServerParser.php file as follows: namespace CrestApps\CodeGenerator\DatabaseParser;
change to: namespace crestapps\laravelCodeGenerator\src\DatabaseParser;
Environment:
Description:
Class CrestApps\CodeGenerator\DatabaseParser\SqlServerParser located in C:/xampp/htdocs/cn/vendor/crestapps/laravel-code-generator/src\DatabaseParsers\SqlServerParser.php does not comply with psr-4 autoloading standard. Skipping. -- Message displayed when trying to require CrestApps in a newly created Laravel project.
Steps/Commands To Reproduce:
Content Of The Resource-File:
SqlServerParser.php: ` namespace CrestApps\CodeGenerator\DatabaseParser;
use App; use CrestApps\CodeGenerator\Models\Field; use CrestApps\CodeGenerator\Models\FieldOptimizer; use CrestApps\CodeGenerator\Support\DatabaseParser\ParserBase; use DB; use Exception;
class SqlServerParser extends ParserBase { /**
@var array */ protected $tableName;
/**
@var array */ protected $databaseName;
/**
@var array */ protected $locale;
/**
@var array */ protected $fields;
/**
@return void */ public function __construct($tableName, $databaseName) { $this->tableName = $tableName; $this->databaseName = $databaseName; $this->locale = App::getLocale(); }
/**
@return array */ public function getFields() { if (is_null($this->fields)) { $columns = $this->getColumn();
}
/**
@return array */ protected function getColumn() { return DB::select( 'SELECT c.COLUMN_NAME ,c.COLUMN_DEFAULT ,c.IS_NULLABLE ,c.DATA_TYPE ,c.CHARACTER_MAXIMUM_LENGTH ,pk.CONSTRAINT_TYPE AS EXTRA FROM INFORMATION_SCHEMA.COLUMNS AS c LEFT JOIN ( SELECT ku.TABLE_CATALOG,ku.TABLE_SCHEMA,ku.TABLE_NAME,ku.COLUMN_NAME, tc.CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ku ON tc.CONSTRAINT_NAME = ku.CONSTRAINT_NAME ) AS pk ON c.TABLE_CATALOG = pk.TABLE_CATALOG AND c.TABLE_SCHEMA = pk.TABLE_SCHEMA AND c.TABLE_NAME = pk.TABLE_NAME AND c.COLUMN_NAME = pk.COLUMN_NAME WHERE c.TABLE_NAME = ? AND c.TABLE_CATALOG = ? ', [$this->tableName, $this->databaseName] ); }
/**
@return array */ protected function transfer(array $columns) { $fields = [];
}
/**
@return $this */ protected function setUnsigned(Field &$field, $type) { if (strpos($type, 'unsigned') !== false) { $field->isUnsigned = true; $field->validationRules[] = sprintf('min:%s', 0); }
}
/**
@return $this */ protected function setHtmlType(Field &$field, $type) { $map = $this->getMap();
}
/**
@return $this */ protected function setDataType(Field &$field, $type) { $map = $this->dataTypeMap();
}
/**
@return $this */ protected function setIsNullable(Field &$field, $nullable) { $field->isNullable = (strtoupper($nullable) == 'YES');
}
/**
@return $this */ protected function setMaxLength(Field &$field, $length) { if (($value = intval($length)) > 0) { $field->validationRules[] = sprintf('max:%s', $value); $field->methodParams[] = $value; }
}
/**
@return $this */ protected function setDefault(Field &$field, $default) { if (!empty($default)) { $field->dataValue = $default; }
}
/**
@return $this */ protected function setLabel(Field &$field, $name) { $field->addLabel($this->getLabelName($name), $this->tableName, true, $this->locale);
}
/**
@return $this */ protected function setKey(Field &$field, $key, $extra) { $key = strtoupper($key);
}
/**
@return string */ protected function getLabelName($name) { return trim(ucwords(strreplace(['-', ''], ' ', $name))); }
/**
@return array */ protected function getMap() { return config('codegenerator.eloquent_type_to_html_type'); }
/**
composer.json:
{ "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "require": { "php": "^7.3|^8.0", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.12", "laravel/tinker": "^2.5", "laravel/ui": "^3.1" }, "require-dev": { "crestapps/laravel-code-generator": "^2.4", "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^5.0", "phpunit/phpunit": "^9.3.3" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "extra": { "laravel": { "dont-discover": [] } }, "autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] } }