I have some helpers in my factories directory (database\factories\FactoryHelpers.php)
<?php
class FactoryHelpers
{
...
}
Now I try to use it in my tests, and get class FactoryHelpers not found
I thought that putting
"classmap": [
"database/factories"
],
In my composer file should be enough to make the FactoryHelpers class available globally.
EDIT:
composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-cors": "^0.9.3",
"fideloper/proxy": "~3.3",
"guzzlehttp/guzzle": "^6.0",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"webpatser/laravel-uuid": "^3.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "v2.4.1",
"codeception/codeception": "^2.3",
"doctrine/dbal": "^2.6",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"krlove/eloquent-model-generator": "^1.2",
"mockery/mockery": "0.9.*",
"mpociot/laravel-test-factory-helper": "^0.5.0",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Related
I have an old project with laravel 5.8;
I've tried to update to 6 & 7 & 8, no luck.
I just want to know where to start from. Right now, all i'm doing is changing versions of different packages...Should i remove any lines or what? What all ways do you upgrade a really old project?
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"aporat/store-receipt-validator": "dev-master",
"barryvdh/laravel-debugbar": "^3.0",
"chumper/zipper": "1.0.x",
"doctrine/cache": "^1.6",
"doctrine/dbal": "^2.5",
"google/apiclient": "^2.0",
"intervention/image": "^2.4",
"laravel/framework": "5.8.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.3.0",
"maatwebsite/excel": "~3.1",
"mariuzzo/laravel-js-localization": "^1.4",
"piwik/device-detector": "^3.9",
"spatie/pdf-to-image": "^1.5",
"spatie/laravel-image-optimizer": "^1.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Weltwoche\\": "app/"
},
"files": [
"app/Helpers/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
I want to run composer update on my laravel project but I keep getting this error:
[Seld\JsonLint\ParsingException]
"./composer.json" does not contain valid JSON
Parse error on line 1:
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
I have validated my composer.json on www.jsonlint.com and the json is valid. I don't know what could be the cause.
My composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"anhskohbo/no-captcha": "^2.4",
"fideloper/proxy": "~3.3",
"intervention/image": "^2.4",
"laravel/framework": "5.5.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4.0",
"stripe/stripe-php": "^5.2"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Change your composer.json file according to this:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
}
}
After Changes of composer.json file, must be run this command: composer update
To install the most recent version, run the following command:
For intervention/image package: composer require intervention/image
For laravel/socialite package: composer require laravel/socialite
For No CAPTCHA reCAPTCHA package: composer require anhskohbo/no-captcha
For laravelcollective/html package: composer require laravelcollective/html
For stripe/stripe-php package: composer require stripe/stripe-php
NOTE: This will download latest version of your laravel project
I moved my laravel application to 5.7 :
$ php artisan --version
Laravel Framework 5.7.3
but trying to use new pagination method linksOnEachSide what I found in docs:
$homepage_quizzes_per_page= 2;
$activeQuizVotes= Vote::getByStatus('A')->
getByIsHomepage(true)->
getByIsQuiz(true)->
orderBy('ordering','desc')->
orderBy('created_at','desc')->
leftJoin(\DB::raw('vote_categories as vc '), \DB::raw('vc.id'), '=', \DB::raw('votes.vote_category_id'))->
select(\DB::raw(" votes.*, vc.name as vote_category_name, vc.slug as vote_category_slug"))->
paginate($homepage_quizzes_per_page)->
linksOnEachSide( (int)($homepage_quizzes_per_page/2) );
I got error :
Method Illuminate\Database\Eloquent\Collection::linksOnEachSide does not exist.
If in code above to comment last line with linksOnEachSide - it works ok and I have valid pagination.
My composer.json has :
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"cviebrock/eloquent-sluggable": "^4.5",
"davejamesmiller/laravel-breadcrumbs": "5.x",
"doctrine/dbal": "^2.8",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"itsgoingd/clockwork": "^3.0",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.4.0",
"proengsoft/laravel-jsvalidation": ">2.2.0",
"rap2hpoutre/laravel-log-viewer": "^0.19.1",
"snowfire/beautymail": "dev-master",
"themsaid/laravel-mail-preview": "^2.0",
"wboyz/laravel-enum": "^0.2.1",
"yajra/laravel-datatables-oracle": "^8.7"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.1",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
],
"post-update-cmd": [
"php artisan vendor:publish --provider=\"Proengsoft\\JsValidation\\JsValidationServiceProvider\" --tag=public --force"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Why error and how to fix it ? Some invalid options ? Or I have to update some more libs apart "laravel/framework": "5.7.*" ?
Thanks!
The method has been renamed to onEachSide().
I have no problems loading in multiple resources in my previous laravel applications 5.2.. I just started a new app in laravel 5.5. and i'm noticing that when loading in css and js files, these are stalled in the browser. This makes pageloads superslow. I'm running php artisan serve as usual.
Does anyone have an idea why this is happening?
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"appstract/laravel-bootstrap-components": "^0.2.0",
"fideloper/proxy": "~3.3",
"hesto/multi-auth": "^2.0",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"yajra/laravel-datatables": "^1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
I got an error while trying to run composer update after adding laravel/cashier in my composer.json file.
Below is the screenshot of the error. Don't seem to understand what the error is.
Please, what I'm I missing here?
And my composer.json file is here below
{
"name": "lufficc/xblog",
"description": "A powerful and responsive blog system powered by laravel.",
"keywords": ["blog", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"predis/predis": "^1.1",
"erusev/parsedown": "^1.6",
"qiniu/php-sdk": "^7.0",
"laravel/socialite": "^2.0",
"mews/purifier": "^2.0",
"league/html-to-markdown": "^4.3",
"laravel/tinker": "^1.0",
"laravel/cashier": "~7.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"files":[
"app/Helpers/helpers.php"
],
"psr-4": {
"App\\": "app/",
"Lufficc\\": "app/Lufficc/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}
It is now resolved by adding below code to my composer.json file
"repositories": [
{
"type": "composer",
"url": "https://packagist.org"
},
{ "packagist": false }
]