Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

php-jira-rest-client

> 开发工具
Open source

PHP classes interact Jira with the REST API.

509 stars0 likes0 views
WebsiteGitHub

About

PHP classes interact Jira with the REST API.

PHP JIRA Rest Client

On-Premise only

If you want to interact with Jira cloud instead of On-Premise(Server, Data Center), check out this repository.

From version >= 5.0.0 of this repository this project is only using V2 of the Jira rest API, to use V3 check out this repository.

Requirements

  • PHP >= 8.0
  • php JsonMapper
  • phpdotenv

Installation

  1. Download and Install PHP Composer.

    bash
    curl -sS https://getcomposer.org/installer | php
  2. Next, run the Composer command to install the latest version of php jira rest client.

    bash
    php composer.phar require lesstif/php-jira-rest-client

    or add the following to your composer.json file.

    json
    {
        "require": {
            "lesstif/php-jira-rest-client": "^5.0"
        }
    }
  3. Then run Composer's install or update commands to complete installation.

    bash
    php composer.phar install
  4. After installing, you need to require Composer's autoloader:

    php
    require 'vendor/autoload.php';

Laravel: Once installed, if you are not using automatic package discovery, then you need to register the JiraRestApi\JiraRestApiServiceProvider service provider in your config/app.php.

Configuration

you can choose loads environment variables either 'dotenv' or 'array'.

use dotenv

If you want to use Dotenv based configuration,first of all, you have to install dependency.

bash
composer require vlucas/phpdotenv

then copy .env.example file to .env on your project root.

bash
JIRA_HOST='https://your-jira.host.com'
JIRA_USER='jira-username'
JIRA_PASS='jira-password-OR-api-token'
# if TOKEN_BASED_AUTH set to true, ignore JIRA_USER and JIRA_PASS.
TOKEN_BASED_AUTH=true
PERSONAL_ACCESS_TOKEN='your-access-token-here'
# to enable session cookie authorization
# COOKIE_AUTH_ENABLED=true
# COOKIE_FILE=storage/jira-cookie.txt
# if you are behind a proxy, add proxy settings
PROXY_SERVER='your-proxy-server'
PROXY_PORT='proxy-port'
PROXY_USER='proxy-username'
PROXY_PASSWORD='proxy-password'

Important Note: As of March 15, 2018, in accordance to the Atlassian REST API Policy, Basic auth with password to be deprecated. Instead of password, you should using API token.

Laravel Users: If you are developing with laravel framework(5.x), you must append above configuration to your application .env file.

use array

create Service class with ArrayConfiguration parameter.

…

Usage

Table of Contents

Project

  • Create Project
  • Update Project
  • Delete Project
  • Get Project Info
  • Get All Project list
  • Get Project Components
  • Get Project Type
  • Get Project Version

Custom Field

  • Get All Field list
  • Create Custom Field

Issue

  • Get Issue Info
  • Create Issue
  • Create Issue - bulk
  • Create Sub Task
  • Add Attachment
  • Update issue
    • Update Labels
    • Update Fix Versions
  • Change assignee
  • Remove issue
  • Perform a transition on an issue
  • Perform an advanced search, using the JQL
    • Simple JQL
    • Simple Query with LinkedIssue
    • JQL With pagination
    • Using JQL Query class
  • Remote Issue Link
    • Get Remote Issue Link
    • Create Remote Issue Link
  • Issue time tracking
  • Add worklog in Issue
  • Edit worklog in Issue
  • Get Issue worklog
  • Add watcher to Issue
  • Remove watcher from Issue
  • Send a notification to the recipients
  • Read property
  • Write property

Comment

  • Add comment
  • Get comment
  • Delete comment
  • Update comment

IssueLink

  • Create Issue Link
  • Get Issue LinkType

User

  • Create User
  • Get User Info
  • Find Users
  • Find Assignable Users
  • Find Users by query
  • Delete User
  • Update User

Group

  • Create Group
  • Get Users from group
  • Add User to group
  • Remove User from group

Priority

  • Get All Priority list
  • Get Priority

Attachment

  • Get attachment Info
  • Remove attachment

Version

  • Create version
  • Update version
  • Delete version
  • Get version related issues
  • Get version unresolved issues

Component

  • Create component
  • Update component
  • Delete component

Board

  • Get board list
  • Get board info
  • Get board issues
  • Get board epics

Epic

  • Get epic info

Create Project

Create a new project.

See Jira API reference

…

Update Project

Update a project. Only non null values sent in JSON will be updated in the project.

Values available for the assigneeType field are: 'PROJECT_LEAD' and 'UNASSIGNED'.

See Jira API reference

php
setName('Updated Example')
        ->setProjectTypeKey('software')
        ->setProjectTemplateKey('com.atlassian.jira-software-project-templates:jira-software-project-management')
        ->setDescription('Updated Example Project description')
        ->setLead('new-leader')
        ->setUrl('http://new.example.com')
        ->setAssigneeType('UNASSIGNED')
    ;

    $proj = new ProjectService();

    $pj = $proj->updateProject($p, 'EX');
   
    var_dump($pj);
} catch (JiraRestApi\JiraException $e) {
    print('Error Occured! ' . $e->getMessage());
}

Delete Project

Deletes a project.

See Jira API reference

php
deleteProject('EX');
   
    var_dump($pj);
} catch (JiraRestApi\JiraException $e) {
    print('Error Occured! ' . $e->getMessage());
}

Get Project Info

See Jira API reference

php
get('TEST');
	
    var_dump($p);			
} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage());
}

Get All Project list

See Jira API reference

php
getAllProjects();

    foreach ($prjs as $p) {
        echo sprintf('Project Key:%s, Id:%s, Name:%s, projectCategory: %s\n',
            $p->key, $p->id, $p->name, $p->projectCategory['name']
        );			
    }			
} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage());
}

Get Project Components

See Jira API reference (Get project components)

php
getAllProjects();

    // Extract and show Project Components for every Jira Project
    foreach ($prjs as $p) {
        var_export($proj->getProjectComponents($p->id));
    }
} catch (JiraRestApi\JiraException $e) {
    print('Error Occured! ' . $e->getMessage());
}

Get Project type

See Jira API reference (get all types)

See Jira API reference (get type)

php
getProjectTypes();

    foreach ($prjtyps as $pt) {
        var_dump($pt);
    }

    // get specific project type.
    $pt = $proj->getProjectType('software');
    var_dump($pt);

} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage());
}

Get Project Version

get all project's versions.

See Jira API reference

php
getVersions('TEST');

    foreach ($vers as $v) {
        // $v is  JiraRestApi\Issue\Version
        var_dump($v);
    }
} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage());
}

or get pagenated project's versions.

See Jira API reference

php
 0,
        'maxResults' => 10,
        'orderBy' => 'name',
        //'expand' => null,
    ];

    $proj = new ProjectService();

    $vers = $proj->getVersionsPagenated('TEST', $param);

    foreach ($vers as $v) {
        // $v is  JiraRestApi\Issue\Version
        var_dump($v);
    }
} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage());
}

Get All Field List

See Jira API reference

php
getAllFields(Field::CUSTOM); 
    	
    var_dump($ret);
} catch (JiraRestApi\JiraException $e) {
    $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}

Create Custom Field

See Jira API reference

php
setName('New custom field')
            ->setDescription('Custom field for picking groups')
            ->setType('com.atlassian.jira.plugin.system.customfieldtypes:grouppicker')
            ->setSearcherKey('com.atlassian.jira.plugin.system.customfieldtypes:grouppickersearcher');

    $fieldService = new FieldService();

    $ret = $fieldService->create($field);
    
    var_dump($ret);
} catch (JiraRestApi\JiraException $e) {
    $this->assertTrue(false, 'Field Create Failed : '.$e->getMessage());
}

If you need a list of custom field types(ex. com.atlassian.jira.plugin.system.customfieldtypes:grouppicker) , check out Get All Field list.

Get Issue Info

See Jira API reference

Returns a full representation of the issue for the given issue key.

php
 [  // default: '*all'
            'summary',
            'comment',
        ],
        'expand' => [
            'renderedFields',
            'names',
            'schema',
            'transitions',
            'operations',
            'editmeta',
            'changelog',
        ]
    ];
            
    $issue = $issueService->get('TEST-867', $queryParam);
	
    var_dump($issue->fields);	
} catch (JiraRestApi\JiraException $e) {
	print('Error Occured! ' . $e->getMessage(

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPjirajira-clientjira-rest-apiphp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具