i am using folder structure like
project/
project-repository/
src/
User/
UserInterface.php
UserRepository.php
composer.json
project-services/
src/
User/
UserService.php
Helper/
helpers.php
composer.json
laravel/
app/
config/
public/
...
composer.json
and my repositories folder json is
{
"name": "project/project-repository",
"description": "A Laravel repository package.",
"type": "project",
"version": "1.0.0",
"autoload": {
"psr-4": {
"Repository\\": "src/"
}
},
"authors": [
{
"name": "DEvLoPER"
}
],
"require": {}
}
and my services folder json is
{
"name": "project/project-services",
"description": "A Laravel Services package",
"type": "project",
"version": "1.0.0",
"autoload": {
"psr-4": {
"Service\\": "src/"
},
"files": [
"Helper/helpers.php"
]
},
"authors": [
{
"name": "DEvLoPER"
}
],
"require": {}
}
in my laravel folder json is
"repositories": [
{
"type": "path",
"url": "../project-repository"
},
{
"type": "path",
"url": "../project-service"
}
],
"require": {
"php": "^8.2",
"laravel/framework": "^11.9",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.9",
"project/project-repository": "^1.0",
"project/project-service": "^1.0"
},
In service folder i create a helper folder and helper file i wand access that helper functions from service's file in json i include that but not working showing
Call to undefined function Service\User\curlPostRequest()
here curlPostRequest()
is helper function in service file i call $data = curlPostRequest()
.
How we can achive this i try many time.
from the services folder json file i remove this line
"files": [
"Helper/helpers.php"
]
and iclude in main laravel project jsonfile like
"files": [
"../project-services/Helper/helpers.php"
]