일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- java
- 코드이그나이터
- php
- IPO
- 자바스크립트
- 주식 청약 일정
- 맥
- Oracle
- MYSQL
- 제이쿼리
- 6월 공모주 청약 일정
- 공모주 청약 일정
- jquery
- Stock
- JavaScript
- 공모주
- 오라클
- 리눅스
- Stock ipo
- 7월 공모주 청약 일정
- 주식 청약
- css
- html
- Eclipse
- linux
- 자바
- 공모주 청약
- SQL
- 주식
- codeigniter
- Today
- Total
개발자의 끄적끄적
[php] codeigniter + vue 세팅 [펌] 본문
[php] codeigniter + vue 세팅 [펌]
When you need to use Vue.js(Nuxt) on codeigniter, there is no default way on codeigniter.
So I solve this problem with .htaccess file.
The main concept is just share one root folder.
And basically, this concept is for separate frontend and backend.
Codigniter for Backend. Vue.js for Frontend.
Like this.
Project
|- application
|- frontend (Vuejs)
|- system
|- web
|- index.php
|- composer.json
|- package.json (This is nuxt package.json)
|- nuxt-config.js
There is no package.json in frontend folder.
The nuxt build path is web folder.
That's all.
Using composer scripts for basic package manager.
So, Add scripts in composer.json
{
...
"scripts": {
"build": ["@preset", "@npm-generate"],
"preset": ["@npm-install"],
"npm-generate": "npm run generate",
"npm-install": "npm install",
}
}
And, package.json
{
...
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
}
nuxt.config.js
module.exports = {
...
router: {
base: '/',
},
srcDir: 'frontend/',
generate: {
dir: 'web',
},
};
And setup rewrite rules on .htaccess
RewriteEngine On
DirectoryIndex index.htm index.html index.php
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond $1 !^(index\.php|resources|robots\.txt|favicon\.ico|web/*)
RewriteCond $1 ^(backend/*|api/*|setup/*)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
RewriteCond $1 !^(index\.php|resources|robots\.txt|favicon\.ico|web/*)
RewriteCond $1 !^(backend/*|api/*|setup/*)
RewriteRule ^(.*)$ web/$1 [L,QSA]
For example..
Request => Rewrite
/ => web/index.html (Vue.js)
/backend/user => index.php/backend/user (Codeigniter)
/api/user/11 => index.php/api/user/11 (Codeigniter)
/sub/one => web/sub/one/index.html (Vue.js)
/frontend/sub/one => 404 NOT FOUND
/token/generate => index.php/token/generate (Codeigniter)
When deploy, Just type composer run-script build. That's All
출처 : https://chicrock.tistory.com/category/Develop/CodeIgniter
'개발 > php' 카테고리의 다른 글
[PHP] PHPMailer - SMTP Error: Could not authenticate [펌] (0) | 2020.03.08 |
---|---|
[php] 전화번호 체크 예제 소스 (0) | 2020.03.08 |
[php] 리눅스에서 PID 로 프로세스 동작 유무 체크 (0) | 2020.03.07 |
[PHP] addslashes(), stripslashes() 그리고, get_magic_quotes_gpc() [펌] (0) | 2020.03.07 |
[php] 전화번호 국내 지역화 코드 [펌] (0) | 2020.03.06 |