PHPackages                             samsonasik/ci4-vue - 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. [Framework](/categories/framework)
4. /
5. samsonasik/ci4-vue

ActiveProject[Framework](/categories/framework)

samsonasik/ci4-vue
==================

CodeIgniter4 starter app with Vue.js Integration

0.10.0(1y ago)9066125[2 PRs](https://github.com/samsonasik/ci4-vue/pulls)MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0CI failing

Since Jul 2Pushed 5mo ago7 watchersCompare

[ Source](https://github.com/samsonasik/ci4-vue)[ Packagist](https://packagist.org/packages/samsonasik/ci4-vue)[ Docs](https://codeigniter.com)[ GitHub Sponsors](https://github.com/samsonasik)[ RSS](/packages/samsonasik-ci4-vue/feed)WikiDiscussions master Synced yesterday

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

Example Using Vue.js in CodeIgniter 4 application
=================================================

[](#example-using-vuejs-in-codeigniter-4-application)

[![ci build](https://github.com/samsonasik/ci4-vue/workflows/ci%20build/badge.svg)](https://github.com/samsonasik/ci4-vue/workflows/ci%20build/badge.svg)[![Mutation testing badge](https://camo.githubusercontent.com/67df988e02d286356bda9691a2908a78bac3112226b50fc4bd866aa799a3170d/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324673616d736f6e6173696b2532466369342d7675652532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/samsonasik/ci4-vue/master)[![Code Coverage](https://camo.githubusercontent.com/7b5fdbdd5983963b737ea4dae33a6f13cf5042afa138e03ca92b516bc33e112f/68747470733a2f2f636f6465636f762e696f2f67682f73616d736f6e6173696b2f6369342d7675652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/samsonasik/ci4-vue)[![Downloads](https://camo.githubusercontent.com/8ff3b62c2c701624cc65cc858997591eefa9a9f1684122e95c96418f28cb69a0/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6173696b2f6369342d7675652f646f776e6c6f616473)](https://packagist.org/packages/samsonasik/ci4-vue)

> Version ^0.1.0 is for Vue 3 usage in CodeIgniter 4 application

> For Vue 2 usage in CodeIgniter 4 application, you can use version [~0.0.17](https://github.com/samsonasik/ci4-vue/tree/0.0.x)

Introduction
------------

[](#introduction)

A CodeIgniter 4 Skeleton Application with Vue.js integration.

Features
--------

[](#features)

- SPA application with Vue Router with cached pages after visited.
- Using server side template from CodeIgniter 4, compiled with `Vue.compile()` in Vue.js component's `render()`.
- Using Vuex for state management library, combo with sessionStorage on portfolio page.
- Webpack support for [production](#production)

Setup
-----

[](#setup)

*1.* Run composer create-project command:

```
composer create-project samsonasik/ci4-vue
```

*2.* Copy file `ci4-vue/env` to `ci4-vue/.env`:

```
cp ci4-vue/env ci4-vue/.env
```

*3.* Set environment and app configuration

Open `ci4-vue/.env` and set `CI_ENVIRONMENT`, `app.baseURL`, `app.indexPage`:

```
# file ci4-vue/.env
CI_ENVIRONMENT = development

app.baseURL    = 'http://localhost:8080'
app.indexPage  = ''
```

*4.* Run PHP Development server

```
# go to ci4-vue directory
cd ci4-vue

# run php development server inside ci4-vue directory
php spark serve
```

*5.* Open web browser

Production
----------

[](#production)

For deploy to production purpose, it has `webpack.config.js` in root directory that when we run `webpack` command, we can get `public/js/dist/bundle.js` after run it. If you don't have a `webpack` installed yet in your system, you can install nodejs and install `webpack` and `webpack-cli`:

```
sudo npm install -g webpack
sudo npm install -g webpack-cli
```

So, we can run:

```
webpack

Hash: 8e63a0daee1be975aeb3
Version: webpack 4.43.0
Time: 469ms
Built at: 07/02/2020 6:13:41 PM
                   Asset     Size  Chunks             Chunk Names
public/js/dist/bundle.js  2.7 KiB       0  [emitted]  main
Entrypoint main = public/js/dist/bundle.js
[0] ./public/js/app.js + 4 modules 3.85 KiB {0} [built]
    | ./public/js/app.js 772 bytes [built]
    | ./public/js/create-page.js 924 bytes [built]
    | ./public/js/portfolio.js 1.67 KiB [built]
    | ./public/js/store.js 183 bytes [built]
    | ./public/js/portfolio-store-module.js 353 bytes [built]
```

After it generated, we can update `.env` file as follow:

```
# file .env
CI_ENVIRONMENT = production

app.baseURL    = 'https://www.your-website.com'
app.indexPage  = ''
```

In `app/Views/layout.php`, we have a `ENVIRONMENT` check to use `js/app.js` when on development, and use `/js/dist/bundle.js` on production when exists.

```
// src/App/templates/layout/default.phtml

// ...
