Let me explain a definition of projective dimension which gives the same result as the one given by Sándor Kovács, but without any restriction on the ring or the module we are talking about. This is, by the way, the one chosen by Bourbaki (A.X.8.1).
Let $A$ be a ring.
0) We write $\overline{\mathbb{Z}}=\mathbb{Z}\cup\{-\infty,\infty\}$ and furnish $\overline{\mathbb{Z}}$ with the ordering that extends the canonical ordering on $\mathbb{Z}$ and has $\infty$ as greatest and $-\infty$ as smallest element. We convene that suprema and infima of subsets of subsets of $\overline{\mathbb{Z}}$ are always understood to be taken in $\overline{\mathbb{Z}}$.
1) If $C$ is a complex of $A$-modules and $C_n$ denotes its component of degree $n\in\mathbb{Z}$, then we set $$b_d(C)=\inf\{n\in\mathbb{Z}\mid C_n\neq 0\}$$ and $$b_g(C)=\sup\{n\in\mathbb{Z}\mid C_n\neq 0\},$$ and we call $$l(C)=b_g(C)-b_d(C)$$ the length of $C$. Note that if $C$ is the zero complex then we have $b_d(C)=\infty$ and $b_g(C)=-\infty$, hence $l(C)=-\infty$.
2) If $M$ is an $A$-module and $(P,p)$ is a left resolution of $M$, then the length $l(P)$ of the complex $P$ is called the length of $(P,p)$. Note that if $P$ is the zero complex (which may be the case if and only if $M=0$) then the length of $(P,p)$ is $-\infty$.
3) If $M$ be an $A$-module, then the infimum of the lengths of all projective resolutions of $M$ is called the projective dimension of $M$. Hence, if $M=0$ then we have a projective resolution of length $-\infty$, and thus the projective dimension of $M$ is also $-\infty$. Conversely, if $M$ has projective dimension $-\infty$ then - since every $A$-module has a projective resolution - it necessarily has a projective resolution of length $-\infty$, and thus it follows $M=0$.
Note: This clearly makes sense in every abelian category with enough projectives, and there are obvious variants of the above that yield analogous definitions of injective or flat dimensions.

