Support the ongoing development of Laravel.io →
Packages
Last updated 2 years ago.
0

Hi @unitedmonkeys, the preferred way is to add the package requirements in the package composer.json file

About the error: did you declared a class or alias named Swift? Swift class is used by SwiftMailer, which is a dependency of Laravel

Last updated 2 years ago.
0

All I do is add the AWS package to my package composer file.

Then I do a composer update and then this downloads Swift.

I'm testing my package inside a basic laravel project, this also has Swift in the vendor file - not sure why?

Here's my packages composer file:

 {
"name": "xxx/xxx",
"description": "",
"authors": [
    {
        "name": "xxx",
        "email": "[email protected]"
    }
],
"require": {
    "php": ">=5.3.0",
    "illuminate/support": "4.1.*",
    "intervention/image": "2.*",
    "aws/aws-sdk-php-laravel": "1.*",
    "components/jquery": "1.9.*"
},
"autoload": {
    "classmap": [
        "src/migrations",
        "src/controllers",
        "src/models",
        "src/views"
    ],
    "psr-0": {
        "xxx\\xxx\\": "src/"
    }
},
"minimum-stability": "stable"

}

And here's my test laravel projects composer file:

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
	"laravel/framework": "4.1.*"
},
"autoload": {
	"classmap": [
		"app/commands",
		"app/controllers",
		"app/models",
		"app/database/migrations",
		"app/database/seeds",
		"app/tests/TestCase.php"
	]
},
"scripts": {
	"post-install-cmd": [
		"php artisan clear-compiled",
		"php artisan optimize"
	],
	"post-update-cmd": [
		"php artisan clear-compiled",
		"php artisan optimize"
	],
	"post-create-project-cmd": [
		"php artisan key:generate"
	]
},
"config": {
	"preferred-install": "dist"
},
"minimum-stability": "stable"

}

Last updated 2 years ago.
0

Class Swift already exist (belongs to SwiftMailer). Your package should use a namespace to prevent class name collisions

Last updated 2 years ago.
0

Thanks @Stolz. I've checked out the docs but how to I namespace my package.

At the minute I have this in my composer file:

 "psr-0": {
        "MyCompany\\MyPackage\\": "src/"
    }

My controller sits under, src>controllers>MyPackageController.php

And it's just set up like:

<?php

class MyPackageController extends \BaseController {

Is this correct? How can I namespace the app?

Last updated 2 years ago.
0
<?php namespace MyCompany\MyPackage;

I suggest reading up on namespacing, PSR-0 and PSR-4 autoloading.

Last updated 2 years ago.
0

I've namespaces my package.

Im still having issues:

Fatal error: Cannot redeclare crypt_random_string()

I googled this and some other people seem to be having the same problem, but I could not find a solution.

Any ideas?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.