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

The documentation on spouts doesn't mention composer autoload #958

Closed
tuur29 opened this issue Jun 24, 2017 · 4 comments · Fixed by #959
Closed

The documentation on spouts doesn't mention composer autoload #958

tuur29 opened this issue Jun 24, 2017 · 4 comments · Fixed by #959

Comments

@tuur29
Copy link

tuur29 commented Jun 24, 2017

I was getting the following generic error: Class spouts\privaterss\privaterss does not exist when I tried adding my own spout. After an hour I found that you have to regenerate the composer autoload files. This isn't mentioned on the website yet.

@jtojnar jtojnar added this to the 2.18 milestone Jun 24, 2017
jtojnar added a commit that referenced this issue Jun 24, 2017
When we introduced the use of Composer classmaps for autoloading in
df6f5d0, we lost the ability to define
custom spouts without dumping the autoloader. PSR-4 would fix this issue
but at the time I came to conclusion we would have to change selfoss
file structure to support it.

Since that assumption seems to be false, we are switching to PSR-4, thus
having the cake and eating it too. The only caveat is the need for more
strict file naming conventions.

Closes: #958

::: upgrading:dev
If you use any custom classes like spouts, make sure they follow PSR-4,
namely the namespace should match the file path (even in letter case).

For example, if you have custom spout class named `PrivateSpout` in
`spouts\private` namespace, it will have to be located in
`spouts/private/PrivateSpout.php`.

This also means each file can only contain a single class.

Once you checked the compliance, run `composer dump-autoload -o` to
switch to PSR-4 autoloader.
:::
jtojnar added a commit that referenced this issue Jun 24, 2017
When we introduced the use of Composer classmaps for autoloading in
df6f5d0, we lost the ability to define
custom spouts without dumping the autoloader. PSR-4 would fix this issue
but at the time I came to conclusion we would have to change selfoss
file structure to support it.

Since that assumption seems to be false, we are switching to PSR-4, thus
having the cake and eating it too. The only caveat is the need for more
strict file naming conventions.

Closes: #958

::: upgrading:dev
If you use any custom classes like spouts, make sure they follow PSR-4,
namely the namespace should match the file path (even in letter case).

For example, if you have custom spout class named `PrivateSpout` in
`spouts\private` namespace, it will have to be located in
`spouts/private/PrivateSpout.php`.

This also means each file can only contain a single class.

Once you checked the compliance, run `composer dump-autoload -o` to
switch to PSR-4 autoloader.
:::
jtojnar added a commit that referenced this issue Jun 24, 2017
When we introduced the use of Composer classmaps for autoloading in
df6f5d0, we lost the ability to define
custom spouts without dumping the autoloader. PSR-4 would fix this issue
but at the time I came to conclusion we would have to change selfoss
file structure to support it.

Since that assumption seems to be false, we are switching to PSR-4, thus
having the cake and eating it too. The only caveat is the need for more
strict file naming conventions.

Closes: #958

\### Upgrading (developers)

If you use any custom classes like spouts, make sure they follow the
[PSR-4], namely the namespace should match the file path (even in letter
case).

For example, if you have custom spout class named `PrivateSpout` in
`spouts\private` namespace, it will have to be located in
`spouts/private/PrivateSpout.php`.

This also means each file can only contain a single class.

Once you checked the compliance, run `composer dump-autoload -o` to
switch to PSR-4 autoloader.

[PSR-4]: http://www.php-fig.org/psr/psr-4/
jtojnar added a commit that referenced this issue Jun 24, 2017
When we introduced the use of Composer classmaps for autoloading in
df6f5d0, we lost the ability to define
custom spouts without dumping the autoloader. PSR-4 would fix this issue
but at the time I came to conclusion we would have to change selfoss
file structure to support it.

Since that assumption seems to be false, we are switching to PSR-4, thus
having the cake and eating it too. The only caveat is the need for more
strict file naming conventions.

Closes: #958

### Upgrading (developers)

If you use any custom classes like spouts, make sure they follow the
[PSR-4], namely the namespace should match the file path (even in letter
case).

For example, if you have custom spout class named `PrivateSpout` in
`spouts\private` namespace, it will have to be located in
`spouts/private/PrivateSpout.php`.

This also means each file can only contain a single class.

Once you checked the compliance, run `composer dump-autoload -o` to
switch to PSR-4 autoloader.

[PSR-4]: http://www.php-fig.org/psr/psr-4/
@jtojnar
Copy link
Member

jtojnar commented Jun 24, 2017

Sorry about that, I wanted to use PSR-4 to eliminate the need for autoload dumping but for some reason concluded that file structure would need to be changed and then forgot about it completely. Since the problem does not seem to exist, I migrated selfoss to the standard.

It will be fixed in #959, then initial autoloader generated with composer install or provided with package should suffice.

As for documentation, #957 should take care of it.

jtojnar added a commit that referenced this issue Jun 25, 2017
When we introduced the use of Composer classmaps for autoloading in
df6f5d0, we lost the ability to define
custom spouts without dumping the autoloader. PSR-4 would fix this issue
but at the time I came to conclusion we would have to change selfoss
file structure to support it.

Since that assumption seems to be false, we are switching to PSR-4, thus
having the cake and eating it too. The only caveat is the need for more
strict file naming conventions.

Closes: #958

### Upgrading

If you use any custom classes like spouts, make sure they follow the
[PSR-4], namely the namespace should match the file path (even in letter
case).

For example, if you have custom spout class named `PrivateSpout` in
`spouts\private` namespace, it will have to be located in
`spouts/private/PrivateSpout.php`.

This also means each file can only contain a single class.

[PSR-4]: http://www.php-fig.org/psr/psr-4/

### Upgrading (developers)
Once you checked for compliance, run `composer install` as described in
the [development section] of README to switch to PSR-4 autoloader.

[development section]: https://github.com/SSilence/selfoss/blob/master/README.md#development
@jantman
Copy link

jantman commented Dec 3, 2017

FWIW, I think this still needs further documentation beyond #957. I'm lucky I found this, because I've been banging my head against the wall for a few hours.

I'm not installing from git, I'm actually using a Docker image. I followed the documentation under "Extend" on https://selfoss.aditu.de/ which implied that I could just copy /spouts/rss/feed.php to /spouts/jantman/feed.php, make the relevant changes, and restart the container. I think the docs on that website need to be updated.

I'm honestly still confused about how to make this work. Do I take the updates in #957 to mean that if I want to add a custom spout, unlike what the website says, I have to install from git and use composer and all that? I can't just drop a PHP file in place?

@jtojnar
Copy link
Member

jtojnar commented Dec 3, 2017

@jantman Sorry, 2.17 is broken with regards to this. It was fixed in #959 so you will need to use nightly build. Now the only change is that, you need to make sure the classes follow PSR-4, namely the namespace should match the file path (even in letter case).

@jantman
Copy link

jantman commented Dec 3, 2017

@jtojnar Ahhh ok! Thanks so much, that definitely makes more sense! Thank you so much for your project, and sorry for such a long comment about something that's already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants