https://github.com/locize/laravelphp
laravel2js and js2laravel converter laravel php resource utils
https://github.com/locize/laravelphp
converter javascript json laravel parser php
Last synced: 11 months ago
JSON representation
laravel2js and js2laravel converter laravel php resource utils
- Host: GitHub
- URL: https://github.com/locize/laravelphp
- Owner: locize
- Created: 2018-11-16T09:20:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-13T13:28:05.000Z (over 2 years ago)
- Last Synced: 2025-07-10T02:52:20.731Z (11 months ago)
- Topics: converter, javascript, json, laravel, parser, php
- Language: JavaScript
- Size: 338 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[](https://travis-ci.org/locize/laravelphp) [](https://npmjs.org/package/laravelphp)
## Download
The source is available for download from
[GitHub](https://github.com/locize/laravelphp/archive/master.zip).
Alternatively, you can install using npm:
```sh
npm install --save laravelphp
```
You can then `import` or `require()` laravel as normal:
```js
import laravelphp from 'laravelphp'
// or
const laravelphp = require('laravelphp')
laravelphp.laravel2js(php, (err, res) => {})
```
Or you can direclty `import` or `require()` its functions:
```js
import resx2js from 'laravelphp/laravel2js'
// or
const resx2js = require('laravelphp/cjs/laravel2js')
```
## Usage
```js
const php = ` 'Hello! Let\'s go!',
'key2' => 'An application to manipulate and process laravel php language files',
'key' => [
'nested' => 'laravel Data Manager'
]
];`
const js = {
"key1": "Hello! Let's go!",
"key2": "An application to manipulate and process laravel php language files",
"key": {
"nested": "laravel Data Manager"
}
}
import laravel2js from 'laravelphp/laravel2js'
laravel2js(php, (err, res) => {
// res is like js
});
import js2laravel from 'laravelphp/js2laravel'
js2laravel(js, (err, res) => {
// res is like php
});
```
Omitting the callback returns a promise
```js
const resJs = await laravel2js(php)
const resPhp = await js2laravel(js)
// or
laravel2js(php).then((res) => {})
js2laravel(js).then((res) => {})
```