Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:use in namespace does nothing #34

Closed
mabasic opened this issue Jun 11, 2020 · 2 comments
Closed

:use in namespace does nothing #34

mabasic opened this issue Jun 11, 2020 · 2 comments

Comments

@mabasic
Copy link
Contributor

mabasic commented Jun 11, 2020

This code runs correctly:

(ns hello-world\boot)

(def app (php/new \Laravel\Lumen\Application "/home/mabasic/code/src/test/hello-world/"))

(php/-> app (run))

This code also runs correctly:

(ns hello-world\boot
    (:use \Laravel\Lumen\Application))

(def app (php/new \Laravel\Lumen\Application "/home/mabasic/code/src/test/hello-world/"))

(php/-> app (run))

What is the purpose of (:use \Laravel\Lumen\Application) if the file runs either way?

I was expected to get an exception or error if the php class was not included with :use in the file.

Update: Does (:use \Laravel\Lumen\Application) mean that I can reference that class by just using Application. If so, how can I alias it to something else? Also, how do I use a imported phel library? Did I miss that in the documentation?

@jenshaase
Copy link
Member

Update: Does (:use \Laravel\Lumen\Application) mean that I can reference that class by just using Application.

Correct. You can just use Application now. You can also define an alias:

(ns hello-world\boot
  (:use \Laravel\Lumen\Application :as MyAlias))

Also, how do I use a imported phel library? Did I miss that in the documentation?

Instead of :use you need to use :require.

(ns hello-world\boot
  (:require hello-world\test))

# Call a function in test
(test/my-fn)

Alias is also supported

(ns hello-world\boot
  (:require hello-world\test :as something))

# Call a function in test
(something/my-fn)

The documentation definitely needs some update on this topic!

@mabasic
Copy link
Contributor Author

mabasic commented Jun 11, 2020

Thank you for explaining. On it :)

@mabasic mabasic closed this as completed Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants