Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
94 views

Create A Package With Laravel and Composer - Odt

The document provides instructions for developing a custom Laravel package. It describes steps to: 1) Add the package as a project dependency and map its location in the main application's composer.json. 2) Configure autoloading and namespaces for the package. 3) Set up basic tests and testing configuration for the package.

Uploaded by

Fran Roa Prieto
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Create A Package With Laravel and Composer - Odt

The document provides instructions for developing a custom Laravel package. It describes steps to: 1) Add the package as a project dependency and map its location in the main application's composer.json. 2) Configure autoloading and namespaces for the package. 3) Set up basic tests and testing configuration for the package.

Uploaded by

Fran Roa Prieto
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. In docker-compose.

yml unter app/docker muss ein neues “volume”


hinzugefügt werden:
/path/to/my/vendor/package:/var/www/vendor/myvendor/package:rw

version: '2'
services:
bav:
image: docker.int.sofort.io/mjolnir/bav:latest
hostname: bav
links:
- "database:database"
depends_on:
- database
volumes:
- "../:/var/www:rw"
- "/home/francisco/dev/sofort/laravel-
maintenance:/var/www/vendor/sofort/laravel-maintenance:rw"
# don't forget to set the ini file to enable debugging using xdebug
- "./php/xdebug-additions.ini:/etc/php/7.0/cli/conf.d/xdebug-additions.ini"
- "./php/xdebug-additions.ini:/etc/php/7.0/apache2/conf.d/xdebug-
additions.ini"
ports:
- "2222:22"
- "80:80"
- "443:443"
database:
image: mysql/mysql-server:5.7.16
environment:
- MYSQL_ROOT_HOST=%
- MYSQL_ROOT_PASSWORD=
- MYSQL_DATABASE=bav
- MYSQL_USER=root
- MYSQL_PASSWORD=
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
hostname: database

2. In kickstart.sh muss folgende Zeile einkommentiert werden:


docker exec -i docker_bav_1 sh -c "composer install";

3. Path von package in composer.json der Anwendung


hinzufügen

unter “repositories":

{
"type": "path",
"url": "/path/to/my/vendor/mypackage/"
}
{

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://satis.int.sofort.io/"
},
{
"type": "composer",
"url": "https://satis.int.sofort.io/extern"
},
{
"type": "path",
"url": "/path/to/my/vendor/mypackage/"
}
],
"require": {
"php": ">=5.5.9",
"ext-mbstring": "*",
"ext-fileinfo": "*",
"ext-bcmath": "*",
"laravel/framework": "5.3.*",
"laravelcollective/html": "~5.3",
"league/csv": "^8.1",
"sofort/utils": "^1.0",
"malkusch/bav": "^1.2",
"guzzlehttp/guzzle": "^6.2",
"domnikl/statsd": "^2.2",
"sofort/brokenpipe-client": "~3.0",
"deployer/deployer": "^3.2",
"league/oauth2-client": "^1.4",
"sofort/bank-mapper-service-client": "~3",
"sofort/dailytool-reporter": "^1.0",
"doctrine/dbal": "^2.5",
"sofort/laravel-maintenance": "@dev"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"phpspec/phpspec": "~2.1",
"mikey179/vfsStream": "~1.2",
"brianium/paratest": "~0.14",
"barryvdh/laravel-ide-helper": "^2.2",
"barryvdh/laravel-debugbar": "^2.3",
"symfony/yaml": "~2",
"symfony/dom-crawler": "3.1.*",
"symfony/css-selector": "3.1.*",
"fzaninotto/faker": "^1.6",
"sofort/laravel-testing": "~1.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Sofort\\Bav\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Sofort\\Bav\\Test\\": "tests/helper/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"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"
]
}
}

4. Composer install

5. composer require "vendorname/packagename @dev"

6. Composer init in dem Ordner


{

"name": "sofort/laravel-maintenance",
"description": "Helper for setting the maintenance mode in laravel applications",
"type": "library",
"license": "private",
"authors": [
{
"name": "Team Mjolnir",
"email": "team.mjolnir@sofort.com"
}
],
"repositories": [
{
"type": "composer",
"url": "https://satis.int.sofort.io"
},
{
"type": "composer",
"url": "https://satis.int.sofort.io/extern"
}
],
"require": {
"php": "~7.0",
"laravel/framework": "5.3.*", // IMPORTANT → hier wird die Laravel-App mitgebaut
"phpunit/phpunit": "^5.7"
},
"require-dev": {
"mockery/mockery": "~0.9.4"
},
"autoload": {
"psr-4": {"Sofort\\Laravel\\Maintenance\\": "src"} // // IMPORTANT → Namespaces
fangen immer bei Sofort/Laravel in unseren Packages an. Hier ist wo der autoload.php
anfängt. Der Namespace des Provider muss damit übereinstimmen
},
"autoload-dev": {
"psr-4": {"Sofort\\Laravel\\Maintenance\\": "tests"}
}
}

7. composer install ausführen

8. phpunit installieren und phpunit.xml hinzufügen


<?

xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php" // IMPORTANT
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="DB_CONNECTION" value="mysql_test"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="OAUTH2_SKIP" value="true"/>
<env name="DAILY_TOOL_REPORTING_ENABLED" value="false"/>
</php>
</phpunit>
9. Ordnerstruktur:

package/
src/
PackageProvider.php
tests
vendor

10. README

You might also like