You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: README.md
+17-37Lines changed: 17 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,60 +3,37 @@
3
3
This project provides tools and shows you an easy way to integrate one or more Angular apps into your Laravel project.
4
4
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.
5
5
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)
***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
-
14
6
## Getting Started
15
7
16
8
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.
18
10
19
11
### Installing
20
12
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.
22
15
23
16
```
24
17
cd <your_project_dir>
25
18
composer install
26
19
```
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.
28
20
29
-
---
30
-
**`Important!`**
31
-
Before `composer install` call this command:
21
+
Than install JavaScript dependencies with **npm**.
32
22
33
-
```PHP
34
-
composer config --global process-timeout 2000
23
+
```
24
+
npm install
35
25
```
36
26
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.
46
28
47
29
```
48
-
composer install
49
-
npm install
50
30
npm run ng-init
31
+
npm run ng-compile
51
32
```
52
33
53
-
---
54
-
55
-
56
-
After finishing issue these commands:
34
+
Start development web server.
57
35
58
36
```
59
-
npm run ng-compile
60
37
php artisan serve
61
38
```
62
39
@@ -97,7 +74,10 @@ Next we have:
97
74
**config** holds configuration JS files for each app. In this demo, `app1.config.js` and `app2.config.js`.
98
75
99
76
Only thing they differ is line #14:
100
-
**'app': '/App1',** | **'app': '/App2',**
77
+
78
+
**'app': '/App1',**
79
+
**'app': '/App2',**
80
+
101
81
which points to the locations where apps live.
102
82
103
83
Last directory to mention is **environments**.
@@ -115,7 +95,7 @@ Next we have some files:
115
95
116
96
## `public` Directory
117
97
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.
119
99
120
100
* App1
121
101
* App2
@@ -132,8 +112,8 @@ Basically all of your HTML, CSS, JS and compiled TS files from `angular_apps` ar
132
112
133
113
Before you run commands make sure you **cd** to your Laravel project root directory.
134
114
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.
137
117
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.*
138
118
139
119
***`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
186
166
*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.*
187
167
188
168
**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.
190
170
This is the default host and port when you start development server like this `php artisan serve`.
191
171
However if you have development server started using some other host and/or port you can use this command in combination with `--hp` switch.
0 commit comments