PHPackages                             adhocore/phint - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. adhocore/phint

ActiveLibrary[Templating &amp; Views](/categories/templating)

adhocore/phint
==============

Initializes new PHP project with sane defaults using templates

0.6.1(6y ago)96568[3 PRs](https://github.com/adhocore/phint/pulls)MITPHPPHP &gt;=7.1CI failing

Since Oct 29Pushed 3y ago6 watchersCompare

[ Source](https://github.com/adhocore/phint)[ Packagist](https://packagist.org/packages/adhocore/phint)[ RSS](/packages/adhocore-phint/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (39)Used By (0)

adhocore/phint
--------------

[](#adhocorephint)

Initializes new PHP project with sane defaults using templates. It scaffolds PHP library &amp;/or project to boost your productivity and save time.

For already existing project, run with `--sync` flag to add missing stuffs, see [phint init](#init).

Once you have files in your `src/` or `lib/` you can run [phint docs](#docs) to generate API like documentation in `.md` format and [phint test](#test) to generate basic test stubs with all the structures already maintained.

It helps you be even more lazier! **phint** is continuously evolving and the plan is to make it [big](#todo).

[![Latest Version](https://camo.githubusercontent.com/91f070bbf3aa73c1ce8705a027053c7aa6de1bf3fc184e2fd47ee098219b647a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6164686f636f72652f7068696e742e7376673f7374796c653d666c61742d737175617265)](https://github.com/adhocore/phint/releases)[![Travis Build](https://camo.githubusercontent.com/16494e1b11104c4529a06d36627505f0e35e20483e975196c3732b651dfcb0c1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6164686f636f72652f7068696e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/adhocore/phint?branch=master)[![Scrutinizer CI](https://camo.githubusercontent.com/0370b54daf695cae702c822236f3a9e7ad7a5cc19209914c6d35293578769884/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6164686f636f72652f7068696e742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/adhocore/phint/?branch=master)[![Codecov branch](https://camo.githubusercontent.com/3aca15037bca7216493438a6af0750069fafd3a37f644b8bdc5e501265a8fac9/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6164686f636f72652f7068696e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/adhocore/phint)[![StyleCI](https://camo.githubusercontent.com/8d08a8b655e00975d319edab47895bb534ea37f98a94afcc3445e00954ab36fb/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130383535303637392f736869656c64)](https://styleci.io/repos/108550679)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Tweet](https://camo.githubusercontent.com/cb820a0ecc9645168e33b03925d7f14691262ddbaeaf66a0a91697803d0cba2d/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f687474702f736869656c64732e696f2e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=Scaffold+new+PHP+project+with+sane+defaults+using+templates&url=https://github.com/adhocore/phint&hashtags=php,template,scaffold,initproject)[![Support](https://camo.githubusercontent.com/6687993dc9b60228356720a501b7c197c8c9a82194cac1b1c72d0dea95e6ad32/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d537570706f7274266d6573736167653d254532253944254134266c6f676f3d476974487562)](https://github.com/sponsors/adhocore)

[![Phint Preview](https://camo.githubusercontent.com/583381878efcc6ba1dad06033923adc4d037f18353226f5bd0bff5ec3c5cf04c/68747470733a2f2f696d6775722e636f6d2f4636506b58395a2e706e67 "Phint Preview")](https://camo.githubusercontent.com/583381878efcc6ba1dad06033923adc4d037f18353226f5bd0bff5ec3c5cf04c/68747470733a2f2f696d6775722e636f6d2f4636506b58395a2e706e67)

[Installation](#installation) · [Features](#features) · [Autocompletion](#autocompletion) · [Usage](#usage) · [phint init](#init) · [phint update](#update) · [phint docs](#docs) · [phint test](#test) · [Templating](#templating)

> Phint is powered by [adhocore/cli](https://github.com/adhocore/php-cli)

Installation
------------

[](#installation)

> Requires PHP7.

### Manual

[](#manual)

Download `phint.phar` from [latest release](https://github.com/adhocore/phint/releases/latest). And use it like so `php /path/to/phint.phar [opts] [args]`. Hmm not cool. See Command section below.

### Command

[](#command)

```
# get latest version (you need `jq`)
LATEST_PHINT=`curl --silent "https://api.github.com/repos/adhocore/phint/releases/latest" | jq -r .tag_name`

# download latest phint
curl -sSLo ~/phint.phar "https://github.com/adhocore/phint/releases/download/$LATEST_PHINT/phint.phar"

# make executable
chmod +x ~/phint.phar
sudo ln -s ~/phint.phar /usr/local/bin/phint

# check
phint --help
```

Features
--------

[](#features)

- generate dot files the likes of `.gitignore, .travis.yml, . editorconfig` etc
- generate `LICENSE`, `README.md`, `composer.json`
- generate `CHANGELOG.md` stub, `CONTRIBUTING.md` guide, `ISSUE_TEMPLATE.md` and `PULL_REQUEST_TEMPLATE.md`
- generate binaries if any
- git init
- interactively ask and install all the dev and prod deps
- generate `phpunit.xml`, test `bootstrap.php`
- generate test stubs for all classes/methods corresponding to `src` (`phint test`)
- generate docs for all public class/methods
- export templates to chosen path so it can be customized (`phint export`)
- use custom templates from a path specified by user
- update its own self (`phint update`)

Autocompletion
--------------

[](#autocompletion)

The phint commands and options can be [autocompleted](https://github.com/adhocore/php-cli#autocompletion) if you use zsh shell with oh-my-zsh.

Setting up auto complete:

```
mkdir -p ~/.oh-my-zsh/custom/plugins/ahccli && cd ~/.oh-my-zsh/custom/plugins/ahccli

[ -f ./ahccli.plugin.zsh ] || curl -sSLo ./ahccli.plugin.zsh https://raw.githubusercontent.com/adhocore/php-cli/master/ahccli.plugin.zsh

echo compdef _ahccli phint >> ./ahccli.plugin.zsh

chmod +x ./ahccli.plugin.zsh && source ./ahccli.plugin.zsh && cd -
```

Dont forget to [add](https://github.com/adhocore/php-cli#load-ahccli-plugin) `ahccli` into `plugins=(... ...)` list in `~/.zshrc` file.

Usage
-----

[](#usage)

It can be used to quickly spin off new project containing all basic and default stuffs. The quick steps are as follows:

```
# See options/arguments
phint init --help

# OR (shortcut)
phint i -h

# Below command inits a brand new PHP project in `project-name` folder in current dir
# Missing arguments are interactively collected
phint init project-name

# You can also use config file (with json) to read option values from
phint init project-name --config phint.json
```

Commands
--------

[](#commands)

Each of the commands below should be used like so:

```
cd /path/to/project
phint  [--options] [args]
```

### init

[](#init)

> alias i

Create and Scaffold a bare new PHP project.

***Parameters:***

Dont be intimidated by long list of parameters, you are not required to enter any of them as arguments as they are interactively collected when required.

Also check [config](#example-config) on how to create a reusable json config so you can use `phint` like a *pro*.

```
Arguments:
    The project name without slashes

Options:
  [-b, --bin...]            Executable binaries
  [-c, --no-codecov]        Disable codecov
  [-C, --config]            JSON filepath to read config from
  [-d, --descr]             Project description
  [-D, --dev...]            Developer packages
  [-e, --email]             Vendor email
  [-f, --force]             Run even if the project exists
  [-G, --gh-template]       Use `.github/` as template path
                            By default uses `docs/`
  [-h, --help]              Show help
  [-w, --keywords...]       Project Keywords
  [-L, --license]           License (m: MIT, g: GNULGPL, a: Apache2, b: BSDSimple, i: ISC, w: WTFPL)
  [-n, --name]              Vendor full name
  [-N, --namespace]         Root namespace (use `/` separator)
  [-g, --package]           Packagist name (Without vendor handle)
  [-p, --path]              The project path (Auto resolved)
  [-P, --php]               Minimum PHP version
  [-R, --req...]            Required packages
  [-s, --no-scrutinizer]    Disable scrutinizer
  [-l, --no-styleci]        Disable StyleCI
  [-S, --sync]              Only create missing files
                            Use with caution, take backup if needed
  [-t, --no-travis]         Disable travis
  [-T, --type]              Project type
  [-u, --username]          Vendor handle/username
  [-z, --using]             Reference package
  [-y, --year]              License Year

Usage Examples:
  phint init  --force --descr "Awesome project" --name "YourName" --email you@domain.com
  phint init  --using laravel/lumen --namespace Project/Api --type project
  phint init  --php 7.0 --config /path/to/json --dev mockery/mockery --req adhocore/cli

```

### Example config

[](#example-config)

Parameters sent via command args will have higher precedence than values from config file (`-C --config`).

What can you put in config? Anything but we suggest you put only known options (check `$ phint init --help`)

```
{
  "type": "library",
  "namespace": "Ahc",
  "username": "adhocore",
  "name": "Jitendra Adhikari",
  "email": "jiten.adhikary@gmail.com",
  "php": "7.0",
  "codecov": false,
  "...": "..."
}
```

---

update
------

[](#update)

> alias u

Update Phint to lastest version or rollback to earlier locally installed version.

***Parameters:***

```
Options:
  [-h, --help]         Show help
  [-r, --rollback]     Rollback to earlier version

Usage Examples:
  phint update        Updates to latest version
  phint u             Also updates to latest version
  phint update -r     Rolls back to prev version
  phint u --rollback  Also rolls back to prev version

```

---

docs
----

[](#docs)

> alias d

Generate docs (`.md`) for all public classes and methods from their docblocks.

Ideally you would run it on existing project **or** after you create/update `src/` files.

***Parameters:***

```
Options:
  [-a, --with-abstract]    Create docs for abstract/interface class
  [-h, --help]             Show help
  [-o, --output]           Output file (default README.md). For old project you should use something else
                           (OR mark region with  and  to inject docs)

Usage Examples:
  phint docs               If there is `` and `` region
                           Injects new doc in between them otherwise appends to bottom
  phint d -o docs/api.md   Writes to docs/api.md (Same rule applies regarding inject/append)

```

### Sample docs

[](#sample-docs)

***PHP code***

```
namespace Abc;

/**
 * This is dummy class.
 *
 * It does nothing as of now.
 * Maybe you could fix it?
 */
class Dummy
{
    /**
     * Alpha beta.
     *
     * Example:
     *
     *
     * $dummy = new Dummy;
     * $dummy->alpha('john', true);
     * // '...'
     *
     *
     * @param string $name
     * @param bool   $flag
     *
     * @return string|null
     */
    public function alpha($name, $flag)
    {
        //
    }
}
```

***Generated Markdown***

```
## Dummy

```php
use Abc\Dummy;
\```

> This is dummy class.

It does nothing as of now.
Maybe you could fix it?

### alpha()

> Alpha beta.

```php
alpha(string $name, bool $flag): string|null
\```

Example:

```php
$dummy = new Dummy;
$dummy->alpha('john', true);
// '...'
\```
```

***Preview***

Dummy
-----

[](#dummy)

```
use Ahc\Dummy;
```

> This is dummy class.

It does nothing as of now. Maybe you could fix it?

### alpha()

[](#alpha)

> Alpha beta.

```
alpha(string $name, bool $flag): string|null
```

Example:

```
$dummy = new Dummy;
$dummy->alpha('john', true);
// '...'
```

---

test
----

[](#test)

> alias t

Generate test files with proper classes and test methods analogous to their source counterparts. If a test class already exists, it is skipped. In future we may append test stubs for new methods.

Ideally you would run it on existing project **or** after you create/update `src/` files.

***Parameters:***

```
Options:
  [-a, --with-abstract]    Create stub for abstract/interface class
  [-h, --help]             Show help
  [-n, --naming]           Test method naming format
                           (t: testMethod | m: test_method | i: it_tests_)
  [-p, --phpunit]          Base PHPUnit class to extend from
  [-s, --no-setup]         Dont add setup method
  [-t, --no-teardown]      Dont add teardown method

Usage Examples:
  phint test -n i        With `it_` naming
  phint t --no-teardown  Without `tearDown()`
  phint test -a          With stubs for abstract/interface

```

### Sample test

[](#sample-test)

Generated `tests/Dummy.php` for [Abc\\Dummy](#sample-docs) above:

```
