Skip to content

Commit 113296d

Browse files
committed
Remove npm calls from composer.json
Simplify workflow by removing npm calls from composer.json and update README.md accordingly. Also modify package.json to install the latest version of Angular.
1 parent ee106ab commit 113296d

File tree

6 files changed

+207
-208
lines changed

6 files changed

+207
-208
lines changed

README.md

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,37 @@
33
This project provides tools and shows you an easy way to integrate one or more Angular apps into your Laravel project.
44
You can clone code from here and start integrating or you can do it [without cloning](#set-up-angular-in-existing-laravel-project) code from here if you have existing project or future versions of Laravel have different file stucture.
55

6-
### Prerequisites
7-
8-
* [PHP](http://www.php.net/downloads.php) - if you are on Windows use this link [PHP](http://windows.php.net/download)
9-
* [Composer](https://getcomposer.org/doc/00-intro.md)
10-
* [Node.js](https://nodejs.org/en/download/)
11-
* **npm** - *you will get npm with Node.js installation*
12-
* **Database** - *of your choice, although you don't need it for these examples alone*
13-
146
## Getting Started
157

168
After you clone and install code you can test right away from default Laravel welcome page.
17-
Example has two Angular demo apps to which you can go by clicking the links **App 1** and **App 2** on the home welcome page.
9+
This project has two Angular demo apps to which you can go by clicking the links **Angular App 1** and **Angular App 2** on the home welcome page.
1810

1911
### Installing
2012

21-
Once you have the code, you can set up a database connection just like with any other Laravel project but for this examples alone you don't have to. **cd** to your project directory and use composer to install all the dependencies.
13+
Once you have the code, you can set up a database connection just like with any other Laravel project but for this examples alone you don't have to.
14+
**cd** to your project directory and use composer to install all the dependencies.
2215

2316
```
2417
cd <your_project_dir>
2518
composer install
2619
```
27-
composer will call `npm install` and `npm run ng-init` in the post-install script so, depending on your machine, it will take a minut or more to install Laravel dependencies, npm dependencies and to initialize Angular.
2820

29-
---
30-
**`Important!`**
31-
Before `composer install` call this command:
21+
Than install JavaScript dependencies with **npm**.
3222

33-
```PHP
34-
composer config --global process-timeout 2000
23+
```
24+
npm install
3525
```
3626

37-
You only have to call it once so after you run it one time, forget about it. That means for all following Laravel projects you don't have to call this command after you do it once.
38-
It is needed because composer will time-out and abort processes that run longer than 300 seconds and to make sure things go smoothly we increase that value to 2000.
39-
I strongly recommend using it since I have put `npm install` and `npm run ng-init` in *"post-install-cmd"* script of the **composer.json**.
40-
Dependencies installation and those two commands together can take some time to initially install so be patient.
41-
This command does lots of work and even if you don't see console text updating for some time it hasn't stuck, just does work in the background, so again, be patient.
42-
You will see some warnings, they are nothing serious and you will only do this command once. For later **composer** calls you use `composer update`.
43-
44-
Alternatively you can remove `npm install` and `npm run ng-init` from the **composer.json**'s *"post-install-cmd"* script and call those commands manually right after `composer install`.
45-
In that case workflow would be:
27+
Initialize Agular and compile and publish code with these two commands.
4628

4729
```
48-
composer install
49-
npm install
5030
npm run ng-init
31+
npm run ng-compile
5132
```
5233

53-
---
54-
55-
56-
After finishing issue these commands:
34+
Start development web server.
5735

5836
```
59-
npm run ng-compile
6037
php artisan serve
6138
```
6239

@@ -97,7 +74,10 @@ Next we have:
9774
**config** holds configuration JS files for each app. In this demo, `app1.config.js` and `app2.config.js`.
9875

9976
Only thing they differ is line #14:
100-
**'app': '/App1',** | **'app': '/App2',**
77+
78+
**'app': '/App1',**
79+
**'app': '/App2',**
80+
10181
which points to the locations where apps live.
10282

10383
Last directory to mention is **environments**.
@@ -115,7 +95,7 @@ Next we have some files:
11595

11696
## `public` Directory
11797

118-
After you run `npm run ng-compile` you will notice some new files and directories in your `public` directory.
98+
After you run `npm run ng-init` and `npm run ng-compile` you will notice some new files and directories in your `public` directory.
11999

120100
* App1
121101
* App2
@@ -132,8 +112,8 @@ Basically all of your HTML, CSS, JS and compiled TS files from `angular_apps` ar
132112

133113
Before you run commands make sure you **cd** to your Laravel project root directory.
134114

135-
* **`npm run ng-init`** - *if you delete **Ng** directory you can recreate it with this command.
136-
Also if you use **npm** to update to a new version of Angular you can use this command to update new version to `public/Ng` directory.
115+
* **`npm run ng-init`** - *creates `Ng` directory in `public` and initializes Angular in it.
116+
Also if you use **npm install** or **npm update** to update to a new version of Angular you can use this command to push new version of Angular to `public/Ng` directory.
137117
In that case you don't have to delete `public/Ng` directory, running this command will reinstall all files and add new ones, if any.*
138118

139119
* **`npm run ng-compile`** - *distributes your HTML, JS, CSS files and compiles TS files to JavaScript and distributes them also.*
@@ -186,7 +166,7 @@ You can pass `--build` switch to only remove empty directories and sub-directori
186166
*This command might come handy if you have some empty directories in `public` and/or `angular_apps` after deleting files while running `npm run ng-watch` command.*
187167

188168
**More about `npm run ng-watch`**
189-
If you use `localhost:8000` as your host:port when you start your development server, you can use this command as is.
169+
If you use `127.0.0.1:8000` as your host:port when you start your development server, you can use this command as is.
190170
This is the default host and port when you start development server like this `php artisan serve`.
191171
However if you have development server started using some other host and/or port you can use this command in combination with `--hp` switch.
192172

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
],
3737
"post-install-cmd": [
3838
"Illuminate\\Foundation\\ComposerScripts::postInstall",
39-
"php artisan optimize",
40-
"npm install",
41-
"npm run ng-init"
39+
"php artisan optimize"
4240
],
4341
"post-update-cmd": [
4442
"Illuminate\\Foundation\\ComposerScripts::postUpdate",

0 commit comments

Comments
 (0)