0

Basically I don't know how to start implementing VueJs into my project. Should I use a CDN or require it via NPM? NPM would make it easier to implement VueJs packages.

I have in (my own framework (for learning)) a path /public/ in which a index.php file is located, along with an assets folder (which leads is followed css/js folders).

So the question is, what would you recommend, and how would you implement routing etc.?

2 Answers 2

1

I personally prefer it to be independent and would download the necessary files and integrate it directly.

  1. Download the development version: https://vuejs.org/js/vue.js and the production version: https://vuejs.org/js/vue.min.js
  2. Copy this files into the public/js folder
  3. Add a script tag: <script src="js/vue.min.js"></script>
Sign up to request clarification or add additional context in comments.

2 Comments

If you would want to integrate a new VueJs package, would you just also download the file and put it in js/packages or something? And how would you check for package updates (and update them)?
You could use webpack as a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset. github.com/webpack/webpack
1

I don't get what the really point is on your question, but:

In your case I would use a framework like laravel, symfony, zend, ... This gives you routing and stuff.

If you want to write the framework yourself (for learning, like you've mentioned) the you should take your brain and implement a concept on how you would like to define the routings.

Concerning VueJs: I think there should be no problem using the CDN-Version. It keeps things simple, until you really need to build VueJS on your development-PC (later within your deployment-process).

As said: Do one step after another. First use the simple way. Implement a simple Routing. Use VueJS from CDN. And when things get serious: Extend the code by your needs. Include VueJS via NPM and stuff like that.

2 Comments

My framework and custom routing already work. I've implemented a class that loads any required CSS/JS files and even allows me to add snippets of CSS/JS code into a style/script tag (for testing mostly). My real question is, and sorry for not being clear, what are the best conventions to follow using/installing VueJs into a native PHP project?
It depends... There are two ways, which end up in the same situation: I would suggest to put the VueJS-Files into the webroot of the project. If you build them by yourself using NPM or if you download them and put them "by hand" in the correct location should not make any difference to you, I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.