how to write php code in vue? For example in some created() method?
You can’t, really.
PHP is a “hypertext preprocessor” - it just runs once on the server and delivers a HTML document to the client. So you can’t make calls to PHP from Vue. What you’re probably looking for is AJAX or similar.