<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: temori1919</title>
    <description>The latest articles on DEV Community by temori1919 (@temori1919).</description>
    <link>https://dev.to/temori1919</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F512570%2Fdadd0be9-af8e-4b86-8b0d-fa46c70e2c2b.jpeg</url>
      <title>DEV Community: temori1919</title>
      <link>https://dev.to/temori1919</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/temori1919"/>
    <language>en</language>
    <item>
      <title>Let's make a Composer packages - chapter.2 -- Laravel package</title>
      <dc:creator>temori1919</dc:creator>
      <pubDate>Thu, 10 Dec 2020 00:28:45 +0000</pubDate>
      <link>https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-2-laravel-package-2m4d</link>
      <guid>https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-2-laravel-package-2m4d</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This time I will write the procedure for publishing Laravel's Composr self-made package.&lt;br&gt;
The basic steps are the same as in the previous article, so if you haven't read it yet, we recommend reading this article first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo"&gt;Let's make a Composer packages - chapter.1&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Preparation
&lt;/h2&gt;

&lt;p&gt;Please refer to the previous article for the structure and preparation of directories and files.&lt;/p&gt;

&lt;p&gt;When you create your own package with Laravel, implement the &lt;code&gt;service provider&lt;/code&gt; which is the core of FW called Laravel on the package side as well.&lt;/p&gt;

&lt;p&gt;Since Laravel 5.5, a mechanism called &lt;code&gt;Package Auto Discovery&lt;/code&gt; has been introduced, and the service provider will be automatically loaded by adding the following to the&lt;code&gt;composer.json&lt;/code&gt; of the package to be created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"extra"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"laravel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"providers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="s2"&gt;"Vendor&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;PackageName&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;PackageServiceProvider"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is also possible to create something like a debug tool by creating a route within the &lt;code&gt;service provider&lt;/code&gt; or by inserting middleware in the created route.&lt;/p&gt;

&lt;p&gt;By the way, I have released the following packages.&lt;br&gt;
&lt;a href="https://packagist.org/packages/temori/artisan-browser"&gt;temori/artisan-browser&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is a development tool for displaying a terminal-like screen on a browser, checking the route, and executing the &lt;code&gt;artisan&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gph7ootF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wej32xuh0xyzc90sp42y.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gph7ootF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wej32xuh0xyzc90sp42y.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this package as well, the root is created by the service provider, and the screen of the tool is displayed by adding it to the view displaying html elements, js, and css in the middleware.&lt;/p&gt;

&lt;p&gt;The basic structure is the same as &lt;a href="https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo"&gt;Previous article&lt;/a&gt;, but with a few additional directories for Laravel.&lt;/p&gt;

&lt;p&gt;The following is the directory of the created package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── artisan-browser
│ ├── LICENSE
│ ├── README.md
│ ├── composer.json
│ ├── config
│ │ └── artisanbrowser.php
│ └── src
│ ├── ArtisanBrowser.php &lt;span class="c"&gt;# Core class of this package&lt;/span&gt;
│ ├── ArtisanBrowserServiceProvider.php &lt;span class="c"&gt;#Service Provider&lt;/span&gt;
│ ├── Controllers &lt;span class="c"&gt;#Since the route was generated, the controller to call there&lt;/span&gt;
│ │ ├── AjaxController.php
│ │ └── AssetController.php
│ ├── Facades
│ │ └── ArtisanBrowser.php
│ ├── Logs
│ │ └── HistoryLogger.php
│ ├── Middleware &lt;span class="c"&gt;# Middleware for rendering the html element of the package on all pages&lt;/span&gt;
│ │ └── Inject.php
│ ├── Renderer
│ │ ├── AssetRenderer.php
│ │ └── HtmlRenderer.php
│ ├── Resources
│ │ ├── artisanBrowser.css
│ │ ├── artisanBrowser.js
│ │ ├── image
│ │ │ └── logo.png
│ │ ├── vendor
│ │ │ ├── draggabilly.pkgd.min.js
│ │ │ ├── jquery-1.12.4.min.js
│ │ │ └── suggest.js
│ │ └── views
│ │ └── index.blade.php
│ └── helpers.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a directory as appropriate depending on the package to be created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement package processing
&lt;/h2&gt;

&lt;p&gt;This is also the same as &lt;a href="https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo"&gt;previous article&lt;/a&gt;, but if you want to control the behavior with a configuration file etc.&lt;br&gt;
I think there will be occasions when you want the package user to edit the configuration file.&lt;/p&gt;

&lt;p&gt;In such a case, Laravel has a mechanism to place an asset on the application side, so let's utilize it.&lt;/p&gt;

&lt;p&gt;In the service provider's &lt;code&gt;boot&lt;/code&gt; method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;publishes&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../config/artisanbrowser.php'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;config_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'artisanbrowser.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'config'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you write something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The force option places the file by overwriting even if the file already exists&lt;/span&gt;
php artisan vendor:publish &lt;span class="nt"&gt;--tag&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;config &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--force&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The configuration file is placed on the application side with.&lt;/p&gt;

&lt;p&gt;Alternatively, you can merge the configuration files of the application side and the package under vendor.&lt;/p&gt;

&lt;p&gt;If you define the following in the &lt;code&gt;register&lt;/code&gt; method, you can use the settings on the package side as the default, and if you override only the value you want to change, the settings on the package side and the application side will be merged.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;mergeConfigFrom&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;__DIR__&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'/../config/artisanbrowser.php'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'artisanbrowser'&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Details can be found in the official &lt;a href="https://readouble.com/laravel/5.5/en/packages.html"&gt;Package Development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After the package implementation is completed, the procedure after that is the same as &lt;a href="https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo"&gt;Previous article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;I wrote the flow of the &lt;code&gt;Composer&lt;/code&gt; self-made package in two parts. How was it?&lt;br&gt;
I've only written a rough flow, but I hope you'll feel that it's not that high a hurdle: grinning:&lt;/p&gt;

&lt;p&gt;You may want to start by creating a package for your own use.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Let's make a Composer packages - chapter.1</title>
      <dc:creator>temori1919</dc:creator>
      <pubDate>Thu, 10 Dec 2020 00:27:44 +0000</pubDate>
      <link>https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo</link>
      <guid>https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-1-38fo</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I'm sure no one is using PHP and hasn't taken care of Composer, but it's an article for people who want to publish their own packages, not just the ones that are published.&lt;/p&gt;

&lt;p&gt;I hope it helps people who want to do OSS activities but are wondering what the specific steps are.: Blush:&lt;br&gt;
(* I haven't released the package so far, so I'd be happy if you could give me some advice.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://packagist.org/packages/temori/distancexport"&gt;temori/distancexport&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qa5E0SG3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r59mnme6e25gge3zl9pz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qa5E0SG3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r59mnme6e25gge3zl9pz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The above package edits the migration destination column and migration source column in spreadsheet format when data needs to be migrated between DBs or data with different table names or column names is migrated. I created it because I thought it would be convenient if possible.&lt;/p&gt;
&lt;h2&gt;
  
  
  final goals
&lt;/h2&gt;

&lt;p&gt;We will publish it to &lt;a href="https://packagist.org/"&gt;packagist&lt;/a&gt; and aim to install the package with &lt;code&gt;composer require [package name]&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Environment
&lt;/h2&gt;

&lt;p&gt;The development environment is always prepared with &lt;code&gt;docker&lt;/code&gt;.&lt;br&gt;
I think you can develop it in your favorite environment.&lt;/p&gt;

&lt;p&gt;By the way, I am developing in the environment of the following repository.&lt;br&gt;
&lt;a href="https://github.com/temori1919/docker-lamp"&gt;temori1919/docker-lamp&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Project creation
&lt;/h2&gt;

&lt;p&gt;First, create a directory for packages.&lt;br&gt;
At a minimum, I think the following directory structure is fine.&lt;/p&gt;

&lt;p&gt;I have created directories under the &lt;code&gt;package&lt;/code&gt; directory with&lt;code&gt;vendor name&lt;/code&gt; and &lt;code&gt;package name&lt;/code&gt;, but I think it doesn't matter if the root directory is the package name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;package
└── vendorname
    └── Package name
        ├── LICENSE
        ├── README.md &lt;span class="c"&gt;# Since it describes the outline of the package, you can create it after it is completed.&lt;/span&gt;
        ├── composer.json &lt;span class="c"&gt;# This file is generated by the composer command described later.&lt;/span&gt;
        ├── .gitignore &lt;span class="c"&gt;# Create any files you want to exclude from git&lt;/span&gt;
        ├── src &lt;span class="c"&gt;# Directory to store the package source&lt;/span&gt;
        └── tests &lt;span class="c"&gt;# Directory to store test code (OK without it)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After creating the directory, create &lt;code&gt;composer.json&lt;/code&gt; with the&lt;code&gt;composer init&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;It's the usual &lt;strong&gt;that file&lt;/strong&gt; that defines an external package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;path/to/package/vendorname/packagename

Execute the &lt;span class="c"&gt;# command to start creating the file interactively&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;composer init

  Welcome to the Composer config generator

This &lt;span class="nb"&gt;command &lt;/span&gt;will guide you through creating your composer.json config.

&lt;span class="c"&gt;#Enter the vendorname/package name and enter (what you enter here will be the vendorname/package name when you publish it externally)&lt;/span&gt;
Package name &lt;span class="o"&gt;(&lt;/span&gt;&amp;lt;vendor&amp;gt;/&amp;lt;name&amp;gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;some/mypackage]:
&lt;span class="c"&gt;# Describes the outline of the package, but it can be blank. (It will be displayed in the outline of packagist described later)&lt;/span&gt;
Description &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;span class="c"&gt;#Producer, it's okay to skip with n&lt;/span&gt;
Author &lt;span class="o"&gt;[&lt;/span&gt;some &amp;lt;some@address.com&amp;gt;, n to skip]:
&lt;span class="c"&gt;#Minimum stability, Enter as it is is no problem&lt;/span&gt;
&lt;span class="c"&gt;# This is the place to describe the stability of the package to be created.&lt;/span&gt;
&lt;span class="c"&gt;# By default, "stable" can only be used with "dev", "alpha", "beta", "RC", and "stable".&lt;/span&gt;
Minimum Stability &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;span class="c"&gt;#Package type, just enter OK&lt;/span&gt;
&lt;span class="c"&gt;#The default is "library" (the type installed under vendor), and there are also "project", "metapackage", and "composer-plugin".&lt;/span&gt;
Package Type &lt;span class="o"&gt;(&lt;/span&gt;e.g. library, project, metapackage, composer-plugin&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;span class="c"&gt;#License type (Please specify the license that suits your purpose)&lt;/span&gt;
License &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;span class="c"&gt;# Find the package you plan to use&lt;/span&gt;
&lt;span class="c"&gt;# I don't plan to use it for the time being, so just enter&lt;/span&gt;
Would you like to define your dependencies &lt;span class="o"&gt;(&lt;/span&gt;require&lt;span class="o"&gt;)&lt;/span&gt; interactively &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;?
Search &lt;span class="k"&gt;for &lt;/span&gt;a package:
&lt;span class="c"&gt;#This is the above dev package&lt;/span&gt;
&lt;span class="c"&gt;# If you plan to use it, you can search here, but you can add it later, so enter it for the time being.&lt;/span&gt;
Would you like to define your dev dependencies &lt;span class="o"&gt;(&lt;/span&gt;require-dev&lt;span class="o"&gt;)&lt;/span&gt; interactively &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;?
Search &lt;span class="k"&gt;for &lt;/span&gt;a package:

It will be a confirmation of the contents described &lt;span class="k"&gt;in &lt;/span&gt;the &lt;span class="c"&gt;# command&lt;/span&gt;
&lt;span class="c"&gt;# If there is no problem, Enter (you can also modify the file directly later)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"name"&lt;/span&gt;: &lt;span class="s2"&gt;"some/mypackage"&lt;/span&gt;,
    &lt;span class="s2"&gt;"license"&lt;/span&gt;: &lt;span class="s2"&gt;"MIT"&lt;/span&gt;,
    &lt;span class="s2"&gt;"require"&lt;/span&gt;: &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

Do you confirm generation &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I think you have &lt;code&gt;composer.json&lt;/code&gt; directly under the package directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mypackage/composer.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The directory is now ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implement package processing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating directories and dummy projects
&lt;/h3&gt;

&lt;p&gt;Create classes and methods under the &lt;code&gt;src&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;When developing a package, &lt;code&gt;composer require&lt;/code&gt; the package in the local directory and proceed with the development.&lt;/p&gt;

&lt;p&gt;First, create a dummy project to install the package to be developed.&lt;br&gt;
It will be in the same level as the &lt;code&gt;package&lt;/code&gt; directory created earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── package
└── dummy-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;There is no problem in creating a project using FW.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go to the created project, create &lt;code&gt;composer.json&lt;/code&gt; and add the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you created a project using FW, add it to the already placed &lt;code&gt;composer.json&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;dummy-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    "repositories": [
        {
            "type": "path",
            "url": "../package/vendorname/packagename"
        }
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now with the &lt;code&gt;vendor/packagename&lt;/code&gt; you specified for &lt;code&gt;composer in it&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require vendorname/packagename
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type the command and the local directory will be installed as a package.&lt;/p&gt;

&lt;p&gt;You can change the installation destination by changing the &lt;code&gt;type&lt;/code&gt; of&lt;code&gt;composer.json&lt;/code&gt;. If &lt;code&gt;repositories&lt;/code&gt; is not specified, the default will search for packages from &lt;a href="https://packagist.org/"&gt;packagist&lt;/a&gt;.&lt;br&gt;
It is possible to change the installation destination such as reading from a local directory with &lt;code&gt;path&lt;/code&gt; and installing directly from a repository hosting service such as github with &lt;code&gt;vcs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;See below for details.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://getcomposer.org/doc/05-repositories.md#types"&gt;https://getcomposer.org/doc/05-repositories.md#types&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Installing with &lt;code&gt;type&lt;/code&gt; set to&lt;code&gt;path&lt;/code&gt; will generate a symbolic link to the local package directory in the &lt;code&gt;vendor&lt;/code&gt; directory containing the packages in the installed project.&lt;/p&gt;

&lt;p&gt;When coding a package, if you change the package under &lt;code&gt;vendor&lt;/code&gt; in the project, it will be reflected in the source of the package directory created in the same hierarchy as the project, so when using the IDE, code jump etc. will occur. It's convenient.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating classes and methods
&lt;/h3&gt;

&lt;p&gt;By the way, I am creating the main class with the package name.&lt;/p&gt;

&lt;p&gt;With this package, the name and structure are as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;├── LICENSE
├── README.md
├── composer.json
├── phpunit.xml
├── resources
│ ├── assets
│ │ ├── css
│ │ │ ├── jexcel.css
│ │ │ └── jsuites.css
│ │ └── js
│ │ ├── jexcel.js
│ │ └── jsuites.js
│ └── views
│ └── index.php
├── src
│ ├── DataBases
│ │ ├── BaseDriver.php
│ │ ├── Connect.php
│ │ └── Drivers
│ │ ├── Mysql.php
│ │ └── Pgsql.php
│ ├── Distancexport.php
│ ├── Provider.php
│ └── Renders
│ └── AssetResponse.php
└── tests
    └── DistancexportTest.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Distancexport.php&lt;/code&gt; is the class file that is the starting point of the package.&lt;/p&gt;

&lt;p&gt;Also, the &lt;code&gt;resources&lt;/code&gt; directory is created because it was necessary to draw a view for this package.&lt;/p&gt;

&lt;p&gt;After creating the class, add the autoload setting to the package &lt;code&gt;composer.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"some / mypackage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"require"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"autoload"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"psr-4"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Some\\Mypackage\\"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"src/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"Some\\Tests\\"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"tests/"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will autoload the &lt;code&gt;src&lt;/code&gt; subordinate in the &lt;code&gt;Some\Mypackage&lt;/code&gt; namespace.&lt;/p&gt;

&lt;p&gt;As for &lt;code&gt;tests&lt;/code&gt;, it is assumed that the test code is stored under the directory, so it will be autoloaded in the namespace of &lt;code&gt;Some\Tests&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also, although it is a namespace that is named when creating a class, the file cannot be read unless it is the namespace set by autoloading.&lt;/p&gt;

&lt;p&gt;The namespace described in &lt;code&gt;composer.json&lt;/code&gt; must be added to the file that describes the namespace to be implemented in the package.&lt;br&gt;
(* In the above example, &lt;code&gt;Some\Mypackage\ClassName&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;If you need an external package, describe it in &lt;code&gt;require&lt;/code&gt; and it will be installed when you&lt;code&gt;composer require&lt;/code&gt; or &lt;code&gt;install&lt;/code&gt; on the project side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make a README.md
&lt;/h2&gt;

&lt;p&gt;Create a README.&lt;/p&gt;

&lt;p&gt;I mainly describe the following items.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;package name
--Badges that display versions, licenses, etc.
It's easy to understand visually, and above all, it's cool: smiley:&lt;/li&gt;
&lt;li&gt;Overview
Describe the outline of the package
--If the package has a UI, gif animations and images
If you have a UI, it would be easier to understand if you had an image. It may also be the created image.&lt;/li&gt;
&lt;li&gt;table of contents
Place a table of contents with links for each heading.&lt;/li&gt;
&lt;li&gt;Characteristic
It is a feature of the package.
--Requirements
It will be the place to describe the corresponding version etc.
--How to install
How to install the package.
Describe with a command so that you can copy and paste.
--How to use
--License&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The package released this time has the following items.&lt;br&gt;
&lt;a href="https://github.com/temori1919/distancexport/blob/master/README.md"&gt;https://github.com/temori1919/distancexport/blob/master/README.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used the following services for badges.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://shields.io/"&gt;shields&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can easily create badges with packages published on &lt;a href="https://packagist.org/"&gt;packegist&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Of course, some badges can be created even if they are not published.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Y9zbIeb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o364m775ahvupic62ii2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Y9zbIeb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o364m775ahvupic62ii2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above is the version of packagist, but if you enter the published vendor name and package name, the URL will be generated with md or html.&lt;/p&gt;

&lt;p&gt;As for the version, it can be generated only after it is published to packagist, so I think that it will be created after publishing the package and tagging the version described later.&lt;/p&gt;

&lt;p&gt;You can also change the style and wording of the badge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a repository on GitHub and push
&lt;/h2&gt;

&lt;p&gt;Let's push the source to the repository.&lt;br&gt;
Create a &lt;code&gt;LICENSE&lt;/code&gt; file after pushing.&lt;/p&gt;

&lt;p&gt;Click &lt;code&gt;Create new file&lt;/code&gt; to create a new file on GitHub.&lt;br&gt;
If you enter &lt;code&gt;LICENSE&lt;/code&gt; in the file name, you will be able to select the license file template.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8LWU4yG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5gx1fjanu0egjyg4wi9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8LWU4yG6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5gx1fjanu0egjyg4wi9o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, select the license that suits your purpose and generate the file.&lt;/p&gt;

&lt;p&gt;Specify the version with ## tag&lt;br&gt;
I think that the following tag creation screen will be displayed by &lt;code&gt;tags&lt;/code&gt;-&amp;gt;&lt;code&gt;Create a new release&lt;/code&gt;, so I will generate tags.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ReP-8Me1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6garx2dpotojbh4761rh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ReP-8Me1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6garx2dpotojbh4761rh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Specify &lt;code&gt;Tag version&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I try to start from &lt;code&gt;v1.0.0&lt;/code&gt;.&lt;br&gt;
It doesn't matter with or without &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;composer recognizes it as a version even with &lt;code&gt;v&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Target&lt;/code&gt; branch is selected next to the&lt;code&gt;Tag version&lt;/code&gt;, but the current latest commit of the &lt;code&gt;master&lt;/code&gt; branch is the this tagged version.&lt;/p&gt;

&lt;p&gt;If there is a title, detailed contents, etc., there is no problem even if it is not described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Publish to packagist
&lt;/h2&gt;

&lt;p&gt;Finally, publish the GitHub repository to packagist.&lt;/p&gt;

&lt;p&gt;If you do not have an account, please create one.&lt;br&gt;
You can also log in with your GitHub account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5Y9b5JF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hzzhbnmtn3i32jnmeba5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5Y9b5JF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hzzhbnmtn3i32jnmeba5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Display the page to submit the package from the &lt;code&gt;Submit&lt;/code&gt; button in the header.&lt;/p&gt;

&lt;p&gt;Enter the URL of the repository in &lt;code&gt;Repository URL&lt;/code&gt; and press the Check button.&lt;/p&gt;

&lt;p&gt;The GitHub repository and packagist are now linked.&lt;br&gt;
Tag information added on GitHub will also be linked as a package version of packagist.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;README.md&lt;/code&gt; added to the repository is also reflected in the package TOP page of packagist.&lt;/p&gt;

&lt;h2&gt;
  
  
  Register the packagist api token on the GitHub webhook
&lt;/h2&gt;

&lt;p&gt;Register the URL of the packagist api on the GitHub webhook.&lt;/p&gt;

&lt;p&gt;By utilizing Webhook, when you update the repository of GitHub, you will be able to automatically reflect the change on the packagist side.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oRyxQKwq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ponvywv2ub0sqvoeiif9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oRyxQKwq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ponvywv2ub0sqvoeiif9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press &lt;code&gt;Show API Token&lt;/code&gt; to show the token.&lt;br&gt;
Click the &lt;code&gt;the docs&lt;/code&gt; link below it to see how to register your GitHub webhook.&lt;/p&gt;

&lt;p&gt;Register WebHook on GitHub using the token that displays the URL described in the above document.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OyZuOEk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/34aeciypynnyaxtyb1tc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OyZuOEk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/34aeciypynnyaxtyb1tc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter as described in the documentation.&lt;/p&gt;

&lt;p&gt;This completes all the work involved in the release.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;If you follow the steps, I don't think publishing a package is such a high hurdle.&lt;/p&gt;

&lt;p&gt;Next time, I will continue with the procedure to publish the Laravel package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/temori1919/let-s-make-a-composer-packages-chapter-2-laravel-package-2m4d"&gt;Let's make a Composer packages - chapter.2 -- Laravel package&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
